/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((module) => {

module.exports = require("@nestjs/core");

/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AdminModule = void 0;
const common_1 = __webpack_require__(3);
const admin_controller_1 = __webpack_require__(4);
const admin_service_1 = __webpack_require__(5);
const configure_1 = __webpack_require__(6);
const config_1 = __webpack_require__(14);
const member_module_1 = __webpack_require__(15);
const db_module_1 = __webpack_require__(75);
const cache_1 = __webpack_require__(53);
const login_module_1 = __webpack_require__(91);
const response_util_1 = __webpack_require__(62);
const menu_module_1 = __webpack_require__(100);
const role_module_1 = __webpack_require__(105);
const auth_guard_1 = __webpack_require__(111);
const core_1 = __webpack_require__(1);
const jwt_verify_1 = __webpack_require__(93);
const dictionary_category_module_1 = __webpack_require__(112);
const dictionary_item_module_1 = __webpack_require__(117);
const merchant_module_1 = __webpack_require__(122);
const device_type_module_1 = __webpack_require__(129);
const device_module_1 = __webpack_require__(134);
const device_params_field_module_1 = __webpack_require__(151);
const device_params_module_1 = __webpack_require__(157);
const alicloud_1 = __webpack_require__(136);
const sys_config_module_1 = __webpack_require__(163);
;
const option_module_1 = __webpack_require__(168);
const order_module_1 = __webpack_require__(173);
const water_bills_module_1 = __webpack_require__(176);
const water_test_module_1 = __webpack_require__(180);
let AdminModule = class AdminModule {
};
exports.AdminModule = AdminModule;
exports.AdminModule = AdminModule = __decorate([
    (0, common_1.Module)({
        imports: [
            jwt_verify_1.JwtVerifyModule,
            configure_1.ConfigureModule.forRoot(config_1.default),
            cache_1.CacheModule,
            db_module_1.DbModule,
            alicloud_1.AlicloudModule.forRootAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        ...config.get('alicloud')
                    };
                },
            }),
            response_util_1.ResponseUtilModule,
            member_module_1.MemberModule,
            login_module_1.LoginModule,
            menu_module_1.MenuModule,
            role_module_1.RoleModule,
            dictionary_category_module_1.DictionaryCategoryModule,
            dictionary_item_module_1.DictionaryItemModule,
            merchant_module_1.MerchantModule,
            device_type_module_1.DeviceTypeModule,
            device_module_1.DeviceModule,
            device_params_field_module_1.DeviceParamsFieldModule,
            device_params_module_1.DeviceParamsModule,
            sys_config_module_1.SysConfigModule,
            option_module_1.OptionModule,
            order_module_1.OrderModule,
            water_bills_module_1.WaterBillsModule,
            water_test_module_1.WaterTestModule,
        ],
        controllers: [admin_controller_1.AdminController],
        providers: [admin_service_1.AdminService, { provide: core_1.APP_GUARD, useClass: auth_guard_1.AuthGuard }],
    })
], AdminModule);


/***/ }),
/* 3 */
/***/ ((module) => {

module.exports = require("@nestjs/common");

/***/ }),
/* 4 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AdminController = void 0;
const common_1 = __webpack_require__(3);
const admin_service_1 = __webpack_require__(5);
const configure_1 = __webpack_require__(6);
let AdminController = class AdminController {
    constructor(adminService, config) {
        this.adminService = adminService;
        this.config = config;
    }
    getHello() {
        console.log(typeof this.config.get("BOOL_VALUE"));
        console.log(this.config.get("DB_USERNAME"));
        return this.adminService.getHello();
    }
};
exports.AdminController = AdminController;
__decorate([
    (0, common_1.Get)(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", String)
], AdminController.prototype, "getHello", null);
exports.AdminController = AdminController = __decorate([
    (0, common_1.Controller)(),
    __metadata("design:paramtypes", [typeof (_a = typeof admin_service_1.AdminService !== "undefined" && admin_service_1.AdminService) === "function" ? _a : Object, typeof (_b = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _b : Object])
], AdminController);


/***/ }),
/* 5 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AdminService = void 0;
const configure_1 = __webpack_require__(6);
const common_1 = __webpack_require__(3);
let AdminService = class AdminService {
    constructor(configure) {
        this.configure = configure;
    }
    getHello() {
        return 'Hello World!';
    }
};
exports.AdminService = AdminService;
exports.AdminService = AdminService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _a : Object])
], AdminService);


/***/ }),
/* 6 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(7), exports);
__exportStar(__webpack_require__(8), exports);


/***/ }),
/* 7 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var ConfigureModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigureModule = void 0;
const common_1 = __webpack_require__(3);
const configure_service_1 = __webpack_require__(8);
const config_1 = __webpack_require__(9);
const config_2 = __webpack_require__(10);
const fs = __webpack_require__(11);
const path = __webpack_require__(12);
const yaml = __webpack_require__(13);
let ConfigureModule = ConfigureModule_1 = class ConfigureModule {
    static async forRoot(load = null) {
        const loads = [config_2.default];
        if (load) {
            loads.push(load);
        }
        try {
            const folderPath = 'config';
            const files = await fs.promises.readdir(folderPath);
            for (const file of files) {
                const filePath = path.join(folderPath, file);
                loads.push(() => {
                    return yaml.load(fs.readFileSync(filePath, 'utf8'));
                });
            }
        }
        catch (err) {
            console.error(err);
        }
        const options = {
            isGlobal: true,
            expandVariables: true,
            load: loads,
            envFilePath: [`.env.${process.env.APP_NAME}`, '.env', `.env.${process.env.NODE_ENV}`]
        };
        return {
            global: true,
            module: ConfigureModule_1,
            providers: [configure_service_1.ConfigureService],
            exports: [configure_service_1.ConfigureService],
            imports: [
                config_1.ConfigModule.forRoot(options)
            ]
        };
    }
};
exports.ConfigureModule = ConfigureModule;
exports.ConfigureModule = ConfigureModule = ConfigureModule_1 = __decorate([
    (0, common_1.Global)()
], ConfigureModule);


/***/ }),
/* 8 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigureService = void 0;
const common_1 = __webpack_require__(3);
const config_1 = __webpack_require__(9);
let ConfigureService = class ConfigureService {
    constructor(configService) {
        this.configService = configService;
    }
    get(propertyPath) {
        return this.configService.get(propertyPath);
    }
};
exports.ConfigureService = ConfigureService;
exports.ConfigureService = ConfigureService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
], ConfigureService);


/***/ }),
/* 9 */
/***/ ((module) => {

module.exports = require("@nestjs/config");

/***/ }),
/* 10 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = () => {
    return {
        wxAccessTokenKey: 'wx:access:token',
        startChargeResKey: 'scr:',
        endChargeResKey: 'ecr:',
        userChargingOrderKey: 'ucing:',
        devicePortChargingKeyReg: 'd:?:p:?',
        deviceIdPortToOrderIdReg: '?:?:oid',
        PstartChargeResKey: 'p:scr:',
        PendChargeResKey: 'p:ecr:',
        PdeviceChargingOrderKey: 'p:dcing:',
        aliToDeviceTopicReg: '/?/?/user/alternating/get',
        deviceMsgListKeys: {
            chargeInfo: 'charge:info:list'
        }
    };
};


/***/ }),
/* 11 */
/***/ ((module) => {

module.exports = require("fs");

/***/ }),
/* 12 */
/***/ ((module) => {

module.exports = require("path");

/***/ }),
/* 13 */
/***/ ((module) => {

module.exports = require("js-yaml");

/***/ }),
/* 14 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = () => {
    return {
        httpPort: 17777,
        apiPrefix: 'backendApi',
        loginFailMaxCount: 5,
        memberDefaultPassword: '123456',
        white: ['/login', '/sysconfig/configs'],
    };
};


/***/ }),
/* 15 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MemberModule = void 0;
const common_1 = __webpack_require__(3);
const member_controller_1 = __webpack_require__(16);
const member_service_1 = __webpack_require__(17);
let MemberModule = class MemberModule {
};
exports.MemberModule = MemberModule;
exports.MemberModule = MemberModule = __decorate([
    (0, common_1.Module)({
        controllers: [member_controller_1.MemberController],
        providers: [member_service_1.MemberService],
        exports: [member_service_1.MemberService]
    })
], MemberModule);


/***/ }),
/* 16 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d, _e, _f, _g;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MemberController = void 0;
const common_1 = __webpack_require__(3);
const member_service_1 = __webpack_require__(17);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
const dto_pipe_1 = __webpack_require__(65);
const page_dto_1 = __webpack_require__(66);
const create_dto_1 = __webpack_require__(69);
const update_dto_1 = __webpack_require__(70);
const resetpwd_dto_1 = __webpack_require__(72);
const changePassword_dto_1 = __webpack_require__(73);
const UpdateDtoInfo_dto_1 = __webpack_require__(74);
let MemberController = class MemberController {
    constructor(service) {
        this.service = service;
    }
    async permissionMenu(req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        const result = await this.service.allMenu(memberId);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async page(dto, req) {
        const result = await this.service.page(dto, req[constant_1.ReqAttrs.MERCHANT_ID], req[constant_1.ReqAttrs.MEMBER_ID]);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async add(dto, req) {
        try {
            const r = await this.service.add(dto, req[constant_1.ReqAttrs.MERCHANT_ID], req[constant_1.ReqAttrs.BELONG], req[constant_1.ReqAttrs.MEMBER_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto, req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id, req) {
        if (id < 1)
            return null;
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async resetpwd(dto) {
        try {
            const r = await this.service.resetPwd(dto.id, dto.password);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async changePwd(dto, req) {
        try {
            const r = await this.service.changePwd(req[constant_1.ReqAttrs.MEMBER_ID], dto.oldpassword, dto.password);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async updateInfo(dto, req) {
        try {
            const r = await this.service.updateInfo(req[constant_1.ReqAttrs.MEMBER_ID], dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.MemberController = MemberController;
__decorate([
    (0, common_1.Get)("permission/menu"),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "permissionMenu", null);
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _c : Object, Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_d = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _d : Object, Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "del", null);
__decorate([
    (0, common_1.Put)('resetpwd'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_e = typeof resetpwd_dto_1.default !== "undefined" && resetpwd_dto_1.default) === "function" ? _e : Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "resetpwd", null);
__decorate([
    (0, common_1.Put)('changePwd'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_f = typeof changePassword_dto_1.default !== "undefined" && changePassword_dto_1.default) === "function" ? _f : Object, Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "changePwd", null);
__decorate([
    (0, common_1.Put)('updateInfo'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_g = typeof UpdateDtoInfo_dto_1.default !== "undefined" && UpdateDtoInfo_dto_1.default) === "function" ? _g : Object, Object]),
    __metadata("design:returntype", Promise)
], MemberController.prototype, "updateInfo", null);
exports.MemberController = MemberController = __decorate([
    (0, common_1.Controller)('member'),
    __metadata("design:paramtypes", [typeof (_a = typeof member_service_1.MemberService !== "undefined" && member_service_1.MemberService) === "function" ? _a : Object])
], MemberController);


/***/ }),
/* 17 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MemberService = void 0;
const common_1 = __webpack_require__(3);
const crypto_1 = __webpack_require__(18);
const db_service_1 = __webpack_require__(19);
const typeorm_1 = __webpack_require__(23);
const cache_1 = __webpack_require__(53);
const dayjs = __webpack_require__(59);
const configure_1 = __webpack_require__(6);
const work_exception_1 = __webpack_require__(60);
let MemberService = class MemberService {
    constructor(db, cache, config) {
        this.db = db;
        this.cache = cache;
        this.config = config;
    }
    generateSalt() {
        return (0, crypto_1.randomUUID)().split('-').pop().toLocaleLowerCase();
    }
    buildPassword(password, salt) {
        password = (0, crypto_1.createHash)('sha256').update(password + salt).digest('hex').toLowerCase();
        return (0, crypto_1.createHash)('sha256').update(password + salt).digest('hex').toLowerCase();
    }
    async verify(account, password, merchantId = 0) {
        const member = await this.db.member.findOne({ account: account, merchantId: merchantId }, ['name', 'password', 'id', 'salt', 'belong', 'canSuper', 'enable']);
        console.log(member);
        if (!member || this.buildPassword(password, member.salt) != member.password) {
            return null;
        }
        return member;
    }
    async allMenu(memberId) {
        return this.permissionMenu(memberId, { id: true, name: true, parentId: true });
    }
    async permissionMenu(memberId, fields = null) {
        const member = await this.db.member.findOne({ id: memberId }, ['roles', 'canSuper']);
        if (!member.canSuper && (!member.roles || member.roles.length == 0))
            return null;
        const where = {};
        if (!member.canSuper) {
            const roles = await this.db.role.find({ id: (0, typeorm_1.In)(member.roles) }, ['menus', 'id', 'enable']);
            const menuIds = [];
            roles.forEach(role => {
                if (!role.enable)
                    return;
                if (role.menus != null && role.menus.length > 0) {
                    role.menus.forEach(id => {
                        if (!menuIds.includes(id)) {
                            menuIds.push(id);
                        }
                    });
                }
            });
            if (menuIds.length == 0)
                return null;
            where.id = (0, typeorm_1.In)(menuIds);
        }
        return this.db.menu.find(where, fields, null, null, { sort: 'DESC', id: 'DESC' });
    }
    async page(dto, merchantId, memberId) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {
            creatorId: memberId,
            merchantId: merchantId
        };
        if (dto.name) {
            where.name = dto.name;
        }
        if (dto.account) {
            where.account = dto.account;
        }
        result.total = await this.db.member.count(where);
        if (result.total > 0) {
            result.rows = await this.db.member.pagination(dto.pageNo, dto.pageSize, where, { id: true, account: true, name: true, roles: true, tel: true, remark: true, enable: true, canSuper: true }, { id: 'DESC' });
            if (result.rows.length > 0) {
                const roleIds = [];
                result.rows.forEach(row => {
                    const roles = row.roles;
                    if (roles) {
                        roles.forEach(role => {
                            if (roleIds.includes(role) == false) {
                                roleIds.push(role);
                            }
                        });
                    }
                });
                let roles = [];
                if (roleIds.length > 0) {
                    roles = await this.db.role.find({ id: (0, typeorm_1.In)(roleIds) }, ['name', 'id']);
                }
                if (roles.length > 0) {
                    result.rows.forEach(row => {
                        const userRoles = row.roles;
                        if (userRoles && userRoles.length > 0) {
                            row.roleNames = [];
                            for (let i = 0; i < roles.length; i++) {
                                if (userRoles.includes(roles[i].id)) {
                                    row.roleNames.push(roles[i].name);
                                }
                            }
                        }
                    });
                }
            }
        }
        return result;
    }
    async add(dto, merchantId, belong, memberId) {
        const lockKey = 'c:m:' + merchantId + ':' + belong + ':' + dto.account;
        const lock = await this.cache.set(lockKey, '1', 10, 'NX');
        if (!lock || (await this.db.member.isExistsByWhere({ merchantId, account: dto.account })))
            throw new work_exception_1.default('已存在相同的账号');
        const member = {
            creatorId: memberId,
            belong: belong,
            merchantId: merchantId,
            createTime: dayjs().unix(),
            ...dto
        };
        member.salt = this.generateSalt();
        member.password = this.buildPassword(member.password || this.config.get('memberDefaultPassword'), member.salt);
        return this.db.member.insert(member);
    }
    async update(dto) {
        let fields = Object.keys(dto);
        if (fields.length == 0)
            return true;
        const row = await this.db.member.findOne({ id: dto.id });
        if (!row || row.canSuper)
            return false;
        let updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (k == 'roles') {
                    if (row[k] && dto[k]) {
                        const m1 = [...row[k]];
                        const m2 = [...dto[k]];
                        m1.sort();
                        m2.sort();
                        if (JSON.stringify(m1) == JSON.stringify(m2))
                            continue;
                    }
                }
                else {
                    if (row[k] == dto[k])
                        continue;
                }
                updateData[k] = dto[k];
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.account && (true == await this.db.member.isExistsByWhere({ account: updateData.account, merchantId: row.merchantId })))
            throw new work_exception_1.default('已存在相同的账号');
        if (updateData.password) {
            updateData.salt = this.generateSalt();
            updateData.password = this.buildPassword(updateData.password, updateData.salt);
        }
        updateData.updateTime = dayjs().unix();
        return this.db.member.update({ id: dto.id }, updateData);
    }
    async del(id) {
        let row = await this.db.member.findOne({ id }, ['id', 'canSuper']);
        if (!row || row.canSuper)
            return false;
        return this.db.member.delete({ id: id });
    }
    async resetPwd(memberId, password) {
        const member = await this.db.member.findOne({ id: memberId }, { password: true, salt: true });
        if (this.buildPassword(password, member.salt) == member.password)
            throw new work_exception_1.default('密码不能和旧密码一样');
        member.salt = this.generateSalt();
        member.password = this.buildPassword(password, member.salt);
        return this.db.member.update({ id: memberId }, member);
    }
    async changePwd(memberId, oldpwd, newpwd) {
        const member = await this.db.member.findOne({ id: memberId }, ['password', 'salt']);
        if (this.buildPassword(oldpwd, member.salt) != member.password)
            throw new work_exception_1.default('旧密码错误');
        if (newpwd == oldpwd)
            throw new work_exception_1.default('新密码不能和旧密码一样');
        member.salt = this.generateSalt();
        member.password = this.buildPassword(newpwd, member.salt);
        return this.db.member.update({ id: memberId }, member);
    }
    async updateInfo(memberId, dto) {
        if (Object.keys(dto).length > 0) {
            return this.db.member.update({ id: memberId }, dto);
        }
        return true;
    }
};
exports.MemberService = MemberService;
exports.MemberService = MemberService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _b : Object, typeof (_c = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _c : Object])
], MemberService);


/***/ }),
/* 18 */
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),
/* 19 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DbService = void 0;
const dictionary_category_repository_service_1 = __webpack_require__(20);
const dictionary_item_repository_service_1 = __webpack_require__(25);
const member_repository_service_1 = __webpack_require__(27);
const menu_repository_service_1 = __webpack_require__(29);
const role_repository_service_1 = __webpack_require__(31);
const sys_config_repository_service_1 = __webpack_require__(33);
const device_params_field_repository_service_1 = __webpack_require__(35);
const device_params_repository_service_1 = __webpack_require__(37);
const device_repository_service_1 = __webpack_require__(39);
const device_type_repository_service_1 = __webpack_require__(41);
const merchant_repository_service_1 = __webpack_require__(43);
const recharge_option_repository_service_1 = __webpack_require__(45);
const user_repository_service_1 = __webpack_require__(47);
const water_bills_repository_service_1 = __webpack_require__(49);
const water_test_repository_service_1 = __webpack_require__(51);
const common_1 = __webpack_require__(3);
let DbService = class DbService {
    constructor(member, role, menu, dictionaryCategory, dictionaryItem, sysConfig, merchant, deviceType, device, deviceParamsField, deviceParams, waterBills, waterTest, user, rechargeOption) {
        this.member = member;
        this.role = role;
        this.menu = menu;
        this.dictionaryCategory = dictionaryCategory;
        this.dictionaryItem = dictionaryItem;
        this.sysConfig = sysConfig;
        this.merchant = merchant;
        this.deviceType = deviceType;
        this.device = device;
        this.deviceParamsField = deviceParamsField;
        this.deviceParams = deviceParams;
        this.waterBills = waterBills;
        this.waterTest = waterTest;
        this.user = user;
        this.rechargeOption = rechargeOption;
    }
};
exports.DbService = DbService;
exports.DbService = DbService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof member_repository_service_1.MemberRepositoryService !== "undefined" && member_repository_service_1.MemberRepositoryService) === "function" ? _a : Object, typeof (_b = typeof role_repository_service_1.RoleRepositoryService !== "undefined" && role_repository_service_1.RoleRepositoryService) === "function" ? _b : Object, typeof (_c = typeof menu_repository_service_1.MenuRepositoryService !== "undefined" && menu_repository_service_1.MenuRepositoryService) === "function" ? _c : Object, typeof (_d = typeof dictionary_category_repository_service_1.DictionaryCategoryRepositoryService !== "undefined" && dictionary_category_repository_service_1.DictionaryCategoryRepositoryService) === "function" ? _d : Object, typeof (_e = typeof dictionary_item_repository_service_1.DictionaryItemRepositoryService !== "undefined" && dictionary_item_repository_service_1.DictionaryItemRepositoryService) === "function" ? _e : Object, typeof (_f = typeof sys_config_repository_service_1.SysConfigRepositoryService !== "undefined" && sys_config_repository_service_1.SysConfigRepositoryService) === "function" ? _f : Object, typeof (_g = typeof merchant_repository_service_1.MerchantRepositoryService !== "undefined" && merchant_repository_service_1.MerchantRepositoryService) === "function" ? _g : Object, typeof (_h = typeof device_type_repository_service_1.DeviceTypeRepositoryService !== "undefined" && device_type_repository_service_1.DeviceTypeRepositoryService) === "function" ? _h : Object, typeof (_j = typeof device_repository_service_1.DeviceRepositoryService !== "undefined" && device_repository_service_1.DeviceRepositoryService) === "function" ? _j : Object, typeof (_k = typeof device_params_field_repository_service_1.DeviceParamsFieldRepositoryService !== "undefined" && device_params_field_repository_service_1.DeviceParamsFieldRepositoryService) === "function" ? _k : Object, typeof (_l = typeof device_params_repository_service_1.DeviceParamsRepositoryService !== "undefined" && device_params_repository_service_1.DeviceParamsRepositoryService) === "function" ? _l : Object, typeof (_m = typeof water_bills_repository_service_1.WaterBillsRepositoryService !== "undefined" && water_bills_repository_service_1.WaterBillsRepositoryService) === "function" ? _m : Object, typeof (_o = typeof water_test_repository_service_1.WaterTestRepositoryService !== "undefined" && water_test_repository_service_1.WaterTestRepositoryService) === "function" ? _o : Object, typeof (_p = typeof user_repository_service_1.UserRepositoryService !== "undefined" && user_repository_service_1.UserRepositoryService) === "function" ? _p : Object, typeof (_q = typeof recharge_option_repository_service_1.RechargeOptionRepositoryService !== "undefined" && recharge_option_repository_service_1.RechargeOptionRepositoryService) === "function" ? _q : Object])
], DbService);


/***/ }),
/* 20 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryCategoryRepositoryService = void 0;
const base_service_1 = __webpack_require__(21);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const DictionaryCategory_1 = __webpack_require__(24);
let DictionaryCategoryRepositoryService = class DictionaryCategoryRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DictionaryCategoryRepositoryService = DictionaryCategoryRepositoryService;
exports.DictionaryCategoryRepositoryService = DictionaryCategoryRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(DictionaryCategory_1.DictionaryCategory)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DictionaryCategoryRepositoryService);


/***/ }),
/* 21 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaseService = void 0;
const common_1 = __webpack_require__(3);
let BaseService = class BaseService {
    getRepository() {
        return this.repository;
    }
    get aliasToOriginalFields() {
        if (!this.aliasToOriginalFieldsMap) {
            this.aliasToOriginalFieldsMap = {};
            this.repository.metadata.ownColumns.forEach(column => {
                this.aliasToOriginalFieldsMap[column.propertyName] = column.databaseName;
            });
        }
        return this.aliasToOriginalFieldsMap;
    }
    get metadata() {
        return this.repository.metadata;
    }
    get tableName() {
        return this.repository.metadata.tableName;
    }
    createQueryBuilder() {
        return this.repository.createQueryBuilder();
    }
    aliasToFields(fields) {
        const aliasToOriginalFieldsMap = this.aliasToOriginalFields;
        return fields.map((field) => `\`${aliasToOriginalFieldsMap[field]}\` as \`${field}\``).join(',');
    }
    createQueryRunner() {
        return this.dataSource.createQueryRunner();
    }
    query(query, parameters) {
        return this.repository.query(query, parameters);
    }
    async count(where) {
        let total = await this.repository.count({
            where: where
        });
        return total;
    }
    async pagination(pageNo, pageSize, where, select, order) {
        pageSize = Number(pageSize);
        return this.find(where, select, (Number(pageNo) - 1) * pageSize, pageSize, order);
    }
    findOne(where, select, order) {
        return this.repository.findOne({
            select: select,
            where: where,
            order: order
        });
    }
    find(where, select, skip, take, order) {
        let options = {};
        if (where) {
            options.where = where;
        }
        if (select) {
            options.select = select;
        }
        if (skip) {
            options.skip = skip;
        }
        if (take) {
            options.take = take;
        }
        if (order) {
            options.order = order;
        }
        return this.repository.find(options);
    }
    async value(where, field) {
        const res = await this.findOne(where, [field]);
        return res ? res[field] : undefined;
    }
    async isExistsByWhere(where) {
        let res = await this.findOne(where, [this.primaryKey]);
        return res ? true : false;
    }
    async save(data, options) {
        return this.repository.save(data, options);
    }
    async saveMany(data, options) {
        return this.repository.save(data, options);
    }
    async insert(data) {
        let result = null;
        try {
            let res = await this.repository.insert(data);
            if (res) {
                let generatedMaps = res.generatedMaps;
                if (generatedMaps && generatedMaps.length > 0) {
                    result = {
                        affectedRows: generatedMaps.length,
                        rows: generatedMaps
                    };
                }
            }
        }
        catch (error) {
            console.log(error);
        }
        return result;
    }
    async update(criteria, partialEntity) {
        try {
            let res = await this.repository.update(criteria, partialEntity);
            return res.affected;
        }
        catch (error) {
            console.log(error);
        }
        return 0;
    }
    async delete(criteria) {
        try {
            let res = await this.repository.delete(criteria);
            return res.affected;
        }
        catch (error) {
        }
        return 0;
    }
};
exports.BaseService = BaseService;
exports.BaseService = BaseService = __decorate([
    (0, common_1.Injectable)()
], BaseService);


/***/ }),
/* 22 */
/***/ ((module) => {

module.exports = require("@nestjs/typeorm");

/***/ }),
/* 23 */
/***/ ((module) => {

module.exports = require("typeorm");

/***/ }),
/* 24 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryCategory = void 0;
const typeorm_1 = __webpack_require__(23);
let DictionaryCategory = class DictionaryCategory {
};
exports.DictionaryCategory = DictionaryCategory;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], DictionaryCategory.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], DictionaryCategory.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "code", length: 20 }),
    __metadata("design:type", String)
], DictionaryCategory.prototype, "code", void 0);
exports.DictionaryCategory = DictionaryCategory = __decorate([
    (0, typeorm_1.Entity)("dictionary_category", { schema: "charge" })
], DictionaryCategory);


/***/ }),
/* 25 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryItemRepositoryService = void 0;
const base_service_1 = __webpack_require__(21);
const DictionaryItem_1 = __webpack_require__(26);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
let DictionaryItemRepositoryService = class DictionaryItemRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DictionaryItemRepositoryService = DictionaryItemRepositoryService;
exports.DictionaryItemRepositoryService = DictionaryItemRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(DictionaryItem_1.DictionaryItem)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DictionaryItemRepositoryService);


/***/ }),
/* 26 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryItem = void 0;
const typeorm_1 = __webpack_require__(23);
let DictionaryItem = class DictionaryItem {
};
exports.DictionaryItem = DictionaryItem;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], DictionaryItem.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], DictionaryItem.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "code", length: 20 }),
    __metadata("design:type", String)
], DictionaryItem.prototype, "code", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "parent_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], DictionaryItem.prototype, "parentId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "category_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], DictionaryItem.prototype, "categoryId", void 0);
exports.DictionaryItem = DictionaryItem = __decorate([
    (0, typeorm_1.Entity)("dictionary_item", { schema: "charge" })
], DictionaryItem);


/***/ }),
/* 27 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MemberRepositoryService = void 0;
const base_service_1 = __webpack_require__(21);
const Member_1 = __webpack_require__(28);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
let MemberRepositoryService = class MemberRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.MemberRepositoryService = MemberRepositoryService;
exports.MemberRepositoryService = MemberRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Member_1.Member)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], MemberRepositoryService);


/***/ }),
/* 28 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Member = void 0;
const typeorm_1 = __webpack_require__(23);
let Member = class Member {
};
exports.Member = Member;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Member.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "account", length: 30 }),
    __metadata("design:type", String)
], Member.prototype, "account", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "password", length: 64 }),
    __metadata("design:type", String)
], Member.prototype, "password", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "salt", length: 12 }),
    __metadata("design:type", String)
], Member.prototype, "salt", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", { name: "belong", comment: "归属", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "belong", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "creator_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "merchant_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "merchantId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "direct_leader", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "directLeader", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "dept_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "deptId", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], Member.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "tel", length: 11 }),
    __metadata("design:type", String)
], Member.prototype, "tel", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "can_super" }),
    __metadata("design:type", Boolean)
], Member.prototype, "canSuper", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "roles", nullable: true, comment: "角色" }),
    __metadata("design:type", Array)
], Member.prototype, "roles", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "remark", length: 100 }),
    __metadata("design:type", String)
], Member.prototype, "remark", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], Member.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], Member.prototype, "updateTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "last_login_time",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Member.prototype, "lastLoginTime", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "last_ip", nullable: true, length: 128 }),
    __metadata("design:type", String)
], Member.prototype, "lastIp", void 0);
exports.Member = Member = __decorate([
    (0, typeorm_1.Entity)("member", { schema: "charge" })
], Member);


/***/ }),
/* 29 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MenuRepositoryService = void 0;
const base_service_1 = __webpack_require__(21);
const Menu_1 = __webpack_require__(30);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
let MenuRepositoryService = class MenuRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.MenuRepositoryService = MenuRepositoryService;
exports.MenuRepositoryService = MenuRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Menu_1.Menu)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], MenuRepositoryService);


/***/ }),
/* 30 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Menu = void 0;
const typeorm_1 = __webpack_require__(23);
let Menu = class Menu {
};
exports.Menu = Menu;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Menu.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], Menu.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "type", length: 10 }),
    __metadata("design:type", String)
], Menu.prototype, "type", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "path", length: 50 }),
    __metadata("design:type", String)
], Menu.prototype, "path", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "component", length: 50 }),
    __metadata("design:type", String)
], Menu.prototype, "component", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "permission", length: 100 }),
    __metadata("design:type", String)
], Menu.prototype, "permission", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "api", length: 100 }),
    __metadata("design:type", String)
], Menu.prototype, "api", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "api_method", length: 10 }),
    __metadata("design:type", String)
], Menu.prototype, "apiMethod", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "keep_alive" }),
    __metadata("design:type", Boolean)
], Menu.prototype, "keepAlive", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "display" }),
    __metadata("design:type", Boolean)
], Menu.prototype, "display", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], Menu.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("smallint", { name: "sort", default: () => "'1'" }),
    __metadata("design:type", Number)
], Menu.prototype, "sort", void 0);
__decorate([
    (0, typeorm_1.Column)("smallint", { name: "parent_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], Menu.prototype, "parentId", void 0);
exports.Menu = Menu = __decorate([
    (0, typeorm_1.Entity)("menu", { schema: "charge" })
], Menu);


/***/ }),
/* 31 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RoleRepositoryService = void 0;
const base_service_1 = __webpack_require__(21);
const Role_1 = __webpack_require__(32);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
let RoleRepositoryService = class RoleRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.RoleRepositoryService = RoleRepositoryService;
exports.RoleRepositoryService = RoleRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Role_1.Role)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], RoleRepositoryService);


/***/ }),
/* 32 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Role = void 0;
const typeorm_1 = __webpack_require__(23);
let Role = class Role {
};
exports.Role = Role;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Role.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "creator_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Role.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], Role.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "menus", nullable: true, comment: "权限菜单集合" }),
    __metadata("design:type", Array)
], Role.prototype, "menus", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "remark", length: 100 }),
    __metadata("design:type", String)
], Role.prototype, "remark", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "enable",
        comment: "是否启用",
    }),
    __metadata("design:type", Boolean)
], Role.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "sort", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Role.prototype, "sort", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], Role.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], Role.prototype, "updateTime", void 0);
exports.Role = Role = __decorate([
    (0, typeorm_1.Entity)("role", { schema: "charge" })
], Role);


/***/ }),
/* 33 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigRepositoryService = void 0;
const base_service_1 = __webpack_require__(21);
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const SysConfig_1 = __webpack_require__(34);
let SysConfigRepositoryService = class SysConfigRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
    async selectValues(code, ...fields) {
        const configs = {};
        if (fields.length > 0) {
            const arr = [];
            fields.forEach(field => {
                arr.push(`JSON_EXTRACT(config, CONCAT('$.', '${field}', '.value')) AS \`${field}\``);
            });
            const items = await this.query(`select ${arr.join(',')} from ${this.tableName} where code = '${code}'`);
            items.forEach(item => {
                for (let k in item) {
                    configs[k] = item[k];
                }
            });
        }
        else {
            const sysConfig = await this.findOne({ code: code });
            if (sysConfig != null) {
                for (let k in sysConfig.config) {
                    configs[k] = sysConfig.config[k].value;
                }
            }
        }
        return configs;
    }
    async selectValue(code, field) {
        const configs = await this.selectValues(code, field);
        return field in configs ? configs[field] : null;
    }
};
exports.SysConfigRepositoryService = SysConfigRepositoryService;
exports.SysConfigRepositoryService = SysConfigRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(SysConfig_1.SysConfig)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], SysConfigRepositoryService);


/***/ }),
/* 34 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfig = void 0;
const typeorm_1 = __webpack_require__(23);
let SysConfig = class SysConfig {
};
exports.SysConfig = SysConfig;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], SysConfig.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 50 }),
    __metadata("design:type", String)
], SysConfig.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "code", length: 50, default: () => "'编码'" }),
    __metadata("design:type", String)
], SysConfig.prototype, "code", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "config", nullable: true, comment: "配置" }),
    __metadata("design:type", Object)
], SysConfig.prototype, "config", void 0);
exports.SysConfig = SysConfig = __decorate([
    (0, typeorm_1.Entity)("sys_config", { schema: "bacsense_water" })
], SysConfig);


/***/ }),
/* 35 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsFieldRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const DeviceParamsField_1 = __webpack_require__(36);
let DeviceParamsFieldRepositoryService = class DeviceParamsFieldRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceParamsFieldRepositoryService = DeviceParamsFieldRepositoryService;
exports.DeviceParamsFieldRepositoryService = DeviceParamsFieldRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(DeviceParamsField_1.DeviceParamsField)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceParamsFieldRepositoryService);


/***/ }),
/* 36 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsField = void 0;
const typeorm_1 = __webpack_require__(23);
let DeviceParamsField = class DeviceParamsField {
};
exports.DeviceParamsField = DeviceParamsField;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], DeviceParamsField.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 100 }),
    __metadata("design:type", String)
], DeviceParamsField.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "input_type", comment: "控件类型", length: 10 }),
    __metadata("design:type", String)
], DeviceParamsField.prototype, "inputType", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "key", comment: "单位", length: 20 }),
    __metadata("design:type", String)
], DeviceParamsField.prototype, "key", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "unit", comment: "单位", length: 10 }),
    __metadata("design:type", String)
], DeviceParamsField.prototype, "unit", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "options", nullable: true, comment: "端口数据" }),
    __metadata("design:type", Object)
], DeviceParamsField.prototype, "options", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], DeviceParamsField.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceParamsField.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceParamsField.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceParamsField.prototype, "updateTime", void 0);
exports.DeviceParamsField = DeviceParamsField = __decorate([
    (0, typeorm_1.Entity)("device_params_field", { schema: "charge" })
], DeviceParamsField);


/***/ }),
/* 37 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const DeviceParams_1 = __webpack_require__(38);
let DeviceParamsRepositoryService = class DeviceParamsRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceParamsRepositoryService = DeviceParamsRepositoryService;
exports.DeviceParamsRepositoryService = DeviceParamsRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(DeviceParams_1.DeviceParams)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceParamsRepositoryService);


/***/ }),
/* 38 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParams = void 0;
const typeorm_1 = __webpack_require__(23);
let DeviceParams = class DeviceParams {
};
exports.DeviceParams = DeviceParams;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], DeviceParams.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 100 }),
    __metadata("design:type", String)
], DeviceParams.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "device_type_id",
        comment: "类型",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceParams.prototype, "deviceTypeId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "merchant_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceParams.prototype, "merchantId", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "params", nullable: true, comment: "参数" }),
    __metadata("design:type", Object)
], DeviceParams.prototype, "params", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceParams.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceParams.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceParams.prototype, "updateTime", void 0);
exports.DeviceParams = DeviceParams = __decorate([
    (0, typeorm_1.Entity)("device_params", { schema: "charge" })
], DeviceParams);


/***/ }),
/* 39 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const Device_1 = __webpack_require__(40);
let DeviceRepositoryService = class DeviceRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceRepositoryService = DeviceRepositoryService;
exports.DeviceRepositoryService = DeviceRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Device_1.Device)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceRepositoryService);


/***/ }),
/* 40 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Device = void 0;
const typeorm_1 = __webpack_require__(23);
let Device = class Device {
};
exports.Device = Device;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Device.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 100 }),
    __metadata("design:type", String)
], Device.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "device_type_id",
        comment: "类型",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "deviceTypeId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "total_water_usage",
        comment: "总用水量",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "totalWaterUsage", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "port_data", nullable: true, comment: "端口数据" }),
    __metadata("design:type", Object)
], Device.prototype, "portData", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "connect_status",
        comment: "链接状态1：是，0：否",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "connectStatus", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "online_time",
        comment: "上线时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "onlineTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "offline_time",
        comment: "离线时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "offlineTime", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "at_ali",
        comment: "是否已经注册到阿里云"
    }),
    __metadata("design:type", Boolean)
], Device.prototype, "atAli", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "ali_id", comment: "阿里云的设备id", length: 32 }),
    __metadata("design:type", String)
], Device.prototype, "aliId", void 0);
__decorate([
    (0, typeorm_1.Column)("char", {
        name: "ali_secret",
        comment: "阿里云的设备Secret",
        length: 32,
    }),
    __metadata("design:type", String)
], Device.prototype, "aliSecret", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "merchant_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "merchantId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "station_id",
        comment: "站点id",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "stationId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "sim", comment: "物联网卡", length: 20 }),
    __metadata("design:type", String)
], Device.prototype, "sim", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "hardware", comment: "硬件", length: 30 }),
    __metadata("design:type", String)
], Device.prototype, "hardware", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "software", comment: "软件", length: 30 }),
    __metadata("design:type", String)
], Device.prototype, "software", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "signal",
        comment: "信号强度",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "signal", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "remark", length: 100 }),
    __metadata("design:type", String)
], Device.prototype, "remark", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "is_private",
        comment: "1：私人的"
    }),
    __metadata("design:type", Boolean)
], Device.prototype, "isPrivate", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], Device.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "updateTime", void 0);
exports.Device = Device = __decorate([
    (0, typeorm_1.Entity)("device", { schema: "charge" })
], Device);


/***/ }),
/* 41 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const DeviceType_1 = __webpack_require__(42);
let DeviceTypeRepositoryService = class DeviceTypeRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceTypeRepositoryService = DeviceTypeRepositoryService;
exports.DeviceTypeRepositoryService = DeviceTypeRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(DeviceType_1.DeviceType)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceTypeRepositoryService);


/***/ }),
/* 42 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceType = void 0;
const typeorm_1 = __webpack_require__(23);
let DeviceType = class DeviceType {
};
exports.DeviceType = DeviceType;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], DeviceType.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 30 }),
    __metadata("design:type", String)
], DeviceType.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "port_count",
        comment: "端口数",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "portCount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "parent_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "parentId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "top_id",
        comment: "最顶级id",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "topId", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "code", length: 20 }),
    __metadata("design:type", String)
], DeviceType.prototype, "code", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "level", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "level", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "ali_product", comment: "阿里云产品", length: 15 }),
    __metadata("design:type", String)
], DeviceType.prototype, "aliProduct", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "param_fields", nullable: true, comment: "参数字段" }),
    __metadata("design:type", Array)
], DeviceType.prototype, "paramFields", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], DeviceType.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "sort",
        comment: "排序越大越靠前",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "sort", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], DeviceType.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], DeviceType.prototype, "updateTime", void 0);
exports.DeviceType = DeviceType = __decorate([
    (0, typeorm_1.Entity)("device_type", { schema: "charge" })
], DeviceType);


/***/ }),
/* 43 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MerchantRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const Merchant_1 = __webpack_require__(44);
let MerchantRepositoryService = class MerchantRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.MerchantRepositoryService = MerchantRepositoryService;
exports.MerchantRepositoryService = MerchantRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Merchant_1.Merchant)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], MerchantRepositoryService);


/***/ }),
/* 44 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Merchant = void 0;
const typeorm_1 = __webpack_require__(23);
let Merchant = class Merchant {
};
exports.Merchant = Merchant;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Merchant.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "parent_id", default: () => "'0'" }),
    __metadata("design:type", Number)
], Merchant.prototype, "parentId", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", comment: "商户名称", length: 20 }),
    __metadata("design:type", String)
], Merchant.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "tel", comment: "电话", length: 20 }),
    __metadata("design:type", String)
], Merchant.prototype, "tel", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "admin_id",
        comment: "管理员id",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Merchant.prototype, "adminId", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "profit_rate",
        comment: "分润比例",
        precision: 3,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], Merchant.prototype, "profitRate", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "payee", comment: "收款人", length: 10 }),
    __metadata("design:type", String)
], Merchant.prototype, "payee", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "account", comment: "收款账号", length: 20 }),
    __metadata("design:type", String)
], Merchant.prototype, "account", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "bank", comment: "银行", length: 20 }),
    __metadata("design:type", String)
], Merchant.prototype, "bank", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        comment: "可提现金额",
        precision: 10,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], Merchant.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "withdrawal_amount",
        comment: "已提现",
        precision: 10,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], Merchant.prototype, "withdrawalAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "frozen_amount",
        comment: "冻结",
        precision: 10,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], Merchant.prototype, "frozenAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "total_charge_order_count",
        comment: "总充电订单数",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Merchant.prototype, "totalChargeOrderCount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "total_charge_amount",
        comment: "总收入",
        precision: 12,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], Merchant.prototype, "totalChargeAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("float", {
        name: "total_charge_kwh",
        unsigned: true,
        precision: 15,
        scale: 5,
        default: () => "'0.00000'",
    }),
    __metadata("design:type", Number)
], Merchant.prototype, "totalChargeKwh", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "total_charge_time",
        comment: "总充电时长，秒",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Merchant.prototype, "totalChargeTime", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], Merchant.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Merchant.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], Merchant.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", default: () => "'0'" }),
    __metadata("design:type", Number)
], Merchant.prototype, "updateTime", void 0);
exports.Merchant = Merchant = __decorate([
    (0, typeorm_1.Entity)("merchant", { schema: "charge" })
], Merchant);


/***/ }),
/* 45 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOptionRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const RechargeOption_1 = __webpack_require__(46);
let RechargeOptionRepositoryService = class RechargeOptionRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.RechargeOptionRepositoryService = RechargeOptionRepositoryService;
exports.RechargeOptionRepositoryService = RechargeOptionRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(RechargeOption_1.RechargeOption)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], RechargeOptionRepositoryService);


/***/ }),
/* 46 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOption = void 0;
const typeorm_1 = __webpack_require__(23);
let RechargeOption = class RechargeOption {
};
exports.RechargeOption = RechargeOption;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], RechargeOption.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        comment: "充值金额",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], RechargeOption.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "reward",
        comment: "奖励金额",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], RechargeOption.prototype, "reward", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "enable",
        comment: "是否启用",
        width: 1,
        default: () => "'0'",
    }),
    __metadata("design:type", Boolean)
], RechargeOption.prototype, "enable", void 0);
exports.RechargeOption = RechargeOption = __decorate([
    (0, typeorm_1.Entity)("recharge_option", { schema: "bacsense_water" })
], RechargeOption);


/***/ }),
/* 47 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const base_service_1 = __webpack_require__(21);
const User_1 = __webpack_require__(48);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
let UserRepositoryService = class UserRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.UserRepositoryService = UserRepositoryService;
exports.UserRepositoryService = UserRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(User_1.User)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], UserRepositoryService);


/***/ }),
/* 48 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.User = void 0;
const typeorm_1 = __webpack_require__(23);
let User = class User {
};
exports.User = User;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], User.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "openid", unique: true, length: 32 }),
    __metadata("design:type", String)
], User.prototype, "openid", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "unionid", length: 32 }),
    __metadata("design:type", String)
], User.prototype, "unionid", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "nickname", length: 50 }),
    __metadata("design:type", String)
], User.prototype, "nickname", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "avatar", length: 100 }),
    __metadata("design:type", String)
], User.prototype, "avatar", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "inviter",
        comment: "邀请人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "inviter", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "phone", nullable: true, length: 11 }),
    __metadata("design:type", String)
], User.prototype, "phone", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", { name: "source", default: () => "'0'" }),
    __metadata("design:type", Number)
], User.prototype, "source", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "payscore",
        comment: "是否开启支付分0,1",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "payscore", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
        transformer: {
            to(value) {
                return String(value || 0);
            },
            from(value) {
                return Number(value || 0);
            }
        }
    }),
    __metadata("design:type", Number)
], User.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "reward_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
        transformer: {
            to(value) {
                return String(value || 0);
            },
            from(value) {
                return Number(value || 0);
            }
        }
    }),
    __metadata("design:type", Number)
], User.prototype, "rewardAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "freeze_amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
        transformer: {
            to(value) {
                return String(value || 0);
            },
            from(value) {
                return Number(value || 0);
            }
        }
    }),
    __metadata("design:type", Number)
], User.prototype, "freezeAmount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "register_time",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "registerTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "last_login_time",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], User.prototype, "lastLoginTime", void 0);
exports.User = User = __decorate([
    (0, typeorm_1.Index)("openid", ["openid"], { unique: true }),
    (0, typeorm_1.Entity)("user", { schema: "bacsense_water" })
], User);


/***/ }),
/* 49 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const WaterBills_1 = __webpack_require__(50);
let WaterBillsRepositoryService = class WaterBillsRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.WaterBillsRepositoryService = WaterBillsRepositoryService;
exports.WaterBillsRepositoryService = WaterBillsRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(WaterBills_1.WaterBills)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], WaterBillsRepositoryService);


/***/ }),
/* 50 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBills = void 0;
const typeorm_1 = __webpack_require__(23);
let WaterBills = class WaterBills {
};
exports.WaterBills = WaterBills;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], WaterBills.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "device_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "deviceId", void 0);
__decorate([
    (0, typeorm_1.Column)("decimal", {
        name: "amount",
        precision: 6,
        scale: 2,
        default: () => "'0.00'",
    }),
    __metadata("design:type", String)
], WaterBills.prototype, "amount", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "water_usage", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "waterUsage", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "tds_raw", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "tdsRaw", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "tds_clean", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterBills.prototype, "tdsClean", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "report_time",
        comment: "上报时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterBills.prototype, "reportTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterBills.prototype, "createTime", void 0);
exports.WaterBills = WaterBills = __decorate([
    (0, typeorm_1.Index)("device_id", ["deviceId"], {}),
    (0, typeorm_1.Entity)("water_bills", { schema: "bacsense_water" })
], WaterBills);


/***/ }),
/* 51 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(22);
const typeorm_2 = __webpack_require__(23);
const base_service_1 = __webpack_require__(21);
const WaterTest_1 = __webpack_require__(52);
let WaterTestRepositoryService = class WaterTestRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.WaterTestRepositoryService = WaterTestRepositoryService;
exports.WaterTestRepositoryService = WaterTestRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(WaterTest_1.WaterTest)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], WaterTestRepositoryService);


/***/ }),
/* 52 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTest = void 0;
const typeorm_1 = __webpack_require__(23);
let WaterTest = class WaterTest {
};
exports.WaterTest = WaterTest;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], WaterTest.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterTest.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "device_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterTest.prototype, "deviceId", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "status",
        comment: "0：等待开启，1：检测中，2：检测失败，3，结束检测，4：检测停止",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterTest.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)("smallint", { name: "result", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], WaterTest.prototype, "result", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "create_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterTest.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "end_time",
        comment: "创建时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], WaterTest.prototype, "endTime", void 0);
exports.WaterTest = WaterTest = __decorate([
    (0, typeorm_1.Index)("device_id", ["deviceId"], {}),
    (0, typeorm_1.Entity)("water_test", { schema: "bacsense_water" })
], WaterTest);


/***/ }),
/* 53 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(54), exports);
__exportStar(__webpack_require__(56), exports);


/***/ }),
/* 54 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CacheModule = void 0;
const common_1 = __webpack_require__(3);
const cache_manager_1 = __webpack_require__(55);
const cache_service_1 = __webpack_require__(56);
const configure_1 = __webpack_require__(6);
const cache_manager_ioredis_yet_1 = __webpack_require__(58);
let CacheModule = class CacheModule {
};
exports.CacheModule = CacheModule;
exports.CacheModule = CacheModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [cache_manager_1.CacheModule.registerAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        store: cache_manager_ioredis_yet_1.redisStore,
                        ...config.get('cache')
                    };
                }
            })],
        providers: [cache_service_1.CacheService],
        exports: [cache_service_1.CacheService],
    })
], CacheModule);


/***/ }),
/* 55 */
/***/ ((module) => {

module.exports = require("@nestjs/cache-manager");

/***/ }),
/* 56 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CacheService = void 0;
const cache_manager_1 = __webpack_require__(55);
const common_1 = __webpack_require__(3);
const cache_manager_2 = __webpack_require__(57);
let CacheService = class CacheService {
    constructor(cacheManager) {
        this.cacheManager = cacheManager;
        this.Client = this.cacheManager.store.client;
    }
    get client() {
        return this.Client;
    }
    async set(...args) {
        let res;
        let argsLen = args.length;
        if (argsLen == 2) {
            res = await this.Client.set(args[0], args[1]);
        }
        else if (argsLen == 3) {
            res = await this.Client.set(args[0], args[1], 'EX', args[2]);
        }
        else if (argsLen == 4) {
            res = await this.Client.set(args[0], args[1], 'EX', args[2], 'NX');
        }
        return res === 'OK';
    }
    pop(key) {
        return this.Client.rpop(key);
    }
    get(key) {
        return this.Client.get(key);
    }
    del(...keys) {
        return this.Client.del(...keys);
    }
    blpop(key, timeout) {
        return this.Client.blpop(key, timeout);
    }
    async blockLock(key, timeout) {
        const len = await this.Client.llen(key);
        if (len == 0) {
            const rs = await this.set(key + ':nx', '1', timeout + 3, 'NX');
            if (rs) {
                return true;
            }
        }
        const res = await this.blpop(key, timeout);
        return res ? true : false;
    }
    async unBlockLock(key) {
        this.Client.lpush(key, '1');
    }
    hmset(key, data) {
        this.Client.hmset(key, data);
    }
    hgetall(key) {
        return this.Client.hgetall(key);
    }
};
exports.CacheService = CacheService;
exports.CacheService = CacheService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
    __metadata("design:paramtypes", [typeof (_a = typeof cache_manager_2.Cache !== "undefined" && cache_manager_2.Cache) === "function" ? _a : Object])
], CacheService);


/***/ }),
/* 57 */
/***/ ((module) => {

module.exports = require("cache-manager");

/***/ }),
/* 58 */
/***/ ((module) => {

module.exports = require("cache-manager-ioredis-yet");

/***/ }),
/* 59 */
/***/ ((module) => {

module.exports = require("dayjs");

/***/ }),
/* 60 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
class WorkException extends Error {
    constructor(message, code = 0) {
        super(message);
        this.isWork = true;
        this.code = code;
        this.name = this.constructor.name;
        Error.captureStackTrace(this, this.constructor);
    }
}
exports["default"] = WorkException;


/***/ }),
/* 61 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MemberBelong = exports.ReqAttrs = void 0;
exports.ReqAttrs = {
    MEMBER_ID: 'memberId',
    IS_SUPER: 'isSuper',
    BELONG: 'belong',
    MERCHANT_ID: 'merchantId'
};
exports.MemberBelong = {
    PLATFORM: 0,
    MERCHANT: 1
};


/***/ }),
/* 62 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(63), exports);
__exportStar(__webpack_require__(64), exports);


/***/ }),
/* 63 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ResponseUtilModule = void 0;
const common_1 = __webpack_require__(3);
const response_util_service_1 = __webpack_require__(64);
let ResponseUtilModule = class ResponseUtilModule {
};
exports.ResponseUtilModule = ResponseUtilModule;
exports.ResponseUtilModule = ResponseUtilModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        providers: [response_util_service_1.ResponseUtilService],
        exports: [response_util_service_1.ResponseUtilService],
    })
], ResponseUtilModule);


/***/ }),
/* 64 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ResponseUtilService = void 0;
const common_1 = __webpack_require__(3);
let ResponseUtilService = class ResponseUtilService {
    static successRes(data = null, params, msg) {
        let result = {
            success: true,
            data: null,
            msg: msg,
            code: 0
        };
        if (data !== null) {
            result.data = data;
        }
        if (params) {
            result = Object.assign(result, params);
        }
        return result;
    }
    static failRes(msg, params) {
        let result = {
            success: false,
            data: null,
            msg: msg,
            code: 0
        };
        if (msg !== undefined) {
            result.msg = msg;
        }
        if (params) {
            result = Object.assign(result, params);
        }
        return result;
    }
};
exports.ResponseUtilService = ResponseUtilService;
exports.ResponseUtilService = ResponseUtilService = __decorate([
    (0, common_1.Injectable)()
], ResponseUtilService);


/***/ }),
/* 65 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DtoPipe = void 0;
const common_1 = __webpack_require__(3);
let DtoPipe = class DtoPipe {
    constructor(options) {
        this.options = {};
        if (options) {
            this.options = options;
        }
    }
    async transform(value, metadata) {
        let v = new common_1.ValidationPipe({
            stopAtFirstError: true,
            skipMissingProperties: false,
            whitelist: true,
            transform: true,
            transformOptions: {},
            exceptionFactory: (errors) => {
                const constraints = errors[0].constraints;
                const keys = Object.keys(constraints);
                throw new common_1.HttpException(constraints[keys[0]], common_1.HttpStatus.FORBIDDEN);
            },
            ...this.options
        });
        return v.transform(value, metadata);
    }
};
exports.DtoPipe = DtoPipe;
exports.DtoPipe = DtoPipe = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof common_1.ValidationPipeOptions !== "undefined" && common_1.ValidationPipeOptions) === "function" ? _a : Object])
], DtoPipe);


/***/ }),
/* 66 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "account", void 0);


/***/ }),
/* 67 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class PaginationDto {
    constructor() {
        this.pageNo = 1;
        this.pageSize = 20;
    }
}
exports["default"] = PaginationDto;
__decorate([
    (0, class_validator_1.IsNumber)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PaginationDto.prototype, "pageNo", void 0);
__decorate([
    (0, class_validator_1.IsNumber)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PaginationDto.prototype, "pageSize", void 0);


/***/ }),
/* 68 */
/***/ ((module) => {

module.exports = require("class-validator");

/***/ }),
/* 69 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "account", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.MinLength)(6),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "password", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(11),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "tel", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsNumber)({}),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "deptId", void 0);
__decorate([
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Array)
], CreateDto.prototype, "depts", void 0);
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Array)
], CreateDto.prototype, "roles", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(100),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "remark", void 0);


/***/ }),
/* 70 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(69);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 71 */
/***/ ((module) => {

module.exports = require("@nestjs/mapped-types");

/***/ }),
/* 72 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class ResetPwdDto {
}
exports["default"] = ResetPwdDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], ResetPwdDto.prototype, "id", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.MinLength)(6),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], ResetPwdDto.prototype, "password", void 0);


/***/ }),
/* 73 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class ChangePassword {
}
exports["default"] = ChangePassword;
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], ChangePassword.prototype, "oldpassword", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.MinLength)(6),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], ChangePassword.prototype, "password", void 0);


/***/ }),
/* 74 */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const update_dto_1 = __webpack_require__(70);
class UpdateDtoInfo extends (0, mapped_types_1.PickType)(update_dto_1.default, ['name']) {
}
exports["default"] = UpdateDtoInfo;


/***/ }),
/* 75 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DbModule = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const member_repository_module_1 = __webpack_require__(76);
const merchant_repository_module_1 = __webpack_require__(77);
const menu_repository_module_1 = __webpack_require__(78);
const role_repository_module_1 = __webpack_require__(79);
const dictionary_category_repository_module_1 = __webpack_require__(80);
const dictionary_item_repository_module_1 = __webpack_require__(81);
const device_type_repository_module_1 = __webpack_require__(82);
const device_repository_module_1 = __webpack_require__(83);
const device_params_field_repository_module_1 = __webpack_require__(84);
const device_params_repository_module_1 = __webpack_require__(85);
const typeorm_1 = __webpack_require__(22);
const configure_1 = __webpack_require__(6);
const recharge_option_repository_module_1 = __webpack_require__(86);
const sys_config_repository_module_1 = __webpack_require__(87);
const water_bills_repository_module_1 = __webpack_require__(88);
const water_test_repository_module_1 = __webpack_require__(89);
const user_repository_module_1 = __webpack_require__(90);
let DbModule = class DbModule {
};
exports.DbModule = DbModule;
exports.DbModule = DbModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [
            typeorm_1.TypeOrmModule.forRootAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        ...config.get('db')
                    };
                },
            }),
            member_repository_module_1.MemberRepositoryModule,
            menu_repository_module_1.MenuRepositoryModule,
            role_repository_module_1.RoleRepositoryModule,
            dictionary_category_repository_module_1.DictionaryCategoryRepositoryModule,
            dictionary_item_repository_module_1.DictionaryItemRepositoryModule,
            sys_config_repository_module_1.SysConfigRepositoryModule,
            merchant_repository_module_1.MerchantRepositoryModule,
            device_type_repository_module_1.DeviceTypeRepositoryModule,
            device_repository_module_1.DeviceRepositoryModule,
            device_params_field_repository_module_1.DeviceParamsFieldRepositoryModule,
            device_params_repository_module_1.DeviceParamsRepositoryModule,
            water_bills_repository_module_1.WaterBillsRepositoryModule,
            water_test_repository_module_1.WaterTestRepositoryModule,
            user_repository_module_1.UserRepositoryModule,
            recharge_option_repository_module_1.RechargeOptionRepositoryModule,
        ],
        providers: [db_service_1.DbService],
        exports: [db_service_1.DbService]
    })
], DbModule);


/***/ }),
/* 76 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MemberRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const member_repository_service_1 = __webpack_require__(27);
const typeorm_1 = __webpack_require__(22);
const Member_1 = __webpack_require__(28);
let MemberRepositoryModule = class MemberRepositoryModule {
};
exports.MemberRepositoryModule = MemberRepositoryModule;
exports.MemberRepositoryModule = MemberRepositoryModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Member_1.Member])],
        providers: [member_repository_service_1.MemberRepositoryService],
        exports: [member_repository_service_1.MemberRepositoryService]
    })
], MemberRepositoryModule);


/***/ }),
/* 77 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MerchantRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const merchant_repository_service_1 = __webpack_require__(43);
const typeorm_1 = __webpack_require__(22);
const Merchant_1 = __webpack_require__(44);
let MerchantRepositoryModule = class MerchantRepositoryModule {
};
exports.MerchantRepositoryModule = MerchantRepositoryModule;
exports.MerchantRepositoryModule = MerchantRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Merchant_1.Merchant])],
        providers: [merchant_repository_service_1.MerchantRepositoryService],
        exports: [merchant_repository_service_1.MerchantRepositoryService]
    })
], MerchantRepositoryModule);


/***/ }),
/* 78 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MenuRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const menu_repository_service_1 = __webpack_require__(29);
const Menu_1 = __webpack_require__(30);
const typeorm_1 = __webpack_require__(22);
let MenuRepositoryModule = class MenuRepositoryModule {
};
exports.MenuRepositoryModule = MenuRepositoryModule;
exports.MenuRepositoryModule = MenuRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Menu_1.Menu])],
        providers: [menu_repository_service_1.MenuRepositoryService],
        exports: [menu_repository_service_1.MenuRepositoryService]
    })
], MenuRepositoryModule);


/***/ }),
/* 79 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RoleRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const role_repository_service_1 = __webpack_require__(31);
const Role_1 = __webpack_require__(32);
const typeorm_1 = __webpack_require__(22);
let RoleRepositoryModule = class RoleRepositoryModule {
};
exports.RoleRepositoryModule = RoleRepositoryModule;
exports.RoleRepositoryModule = RoleRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Role_1.Role])],
        providers: [role_repository_service_1.RoleRepositoryService],
        exports: [role_repository_service_1.RoleRepositoryService]
    })
], RoleRepositoryModule);


/***/ }),
/* 80 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryCategoryRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const dictionary_category_repository_service_1 = __webpack_require__(20);
const typeorm_1 = __webpack_require__(22);
const DictionaryCategory_1 = __webpack_require__(24);
let DictionaryCategoryRepositoryModule = class DictionaryCategoryRepositoryModule {
};
exports.DictionaryCategoryRepositoryModule = DictionaryCategoryRepositoryModule;
exports.DictionaryCategoryRepositoryModule = DictionaryCategoryRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([DictionaryCategory_1.DictionaryCategory])],
        providers: [dictionary_category_repository_service_1.DictionaryCategoryRepositoryService],
        exports: [dictionary_category_repository_service_1.DictionaryCategoryRepositoryService]
    })
], DictionaryCategoryRepositoryModule);


/***/ }),
/* 81 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryItemRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const dictionary_item_repository_service_1 = __webpack_require__(25);
const typeorm_1 = __webpack_require__(22);
const DictionaryItem_1 = __webpack_require__(26);
let DictionaryItemRepositoryModule = class DictionaryItemRepositoryModule {
};
exports.DictionaryItemRepositoryModule = DictionaryItemRepositoryModule;
exports.DictionaryItemRepositoryModule = DictionaryItemRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([DictionaryItem_1.DictionaryItem])],
        providers: [dictionary_item_repository_service_1.DictionaryItemRepositoryService],
        exports: [dictionary_item_repository_service_1.DictionaryItemRepositoryService]
    })
], DictionaryItemRepositoryModule);


/***/ }),
/* 82 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_type_repository_service_1 = __webpack_require__(41);
const typeorm_1 = __webpack_require__(22);
const DeviceType_1 = __webpack_require__(42);
let DeviceTypeRepositoryModule = class DeviceTypeRepositoryModule {
};
exports.DeviceTypeRepositoryModule = DeviceTypeRepositoryModule;
exports.DeviceTypeRepositoryModule = DeviceTypeRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([DeviceType_1.DeviceType])],
        providers: [device_type_repository_service_1.DeviceTypeRepositoryService],
        exports: [device_type_repository_service_1.DeviceTypeRepositoryService]
    })
], DeviceTypeRepositoryModule);


/***/ }),
/* 83 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_repository_service_1 = __webpack_require__(39);
const typeorm_1 = __webpack_require__(22);
const Device_1 = __webpack_require__(40);
let DeviceRepositoryModule = class DeviceRepositoryModule {
};
exports.DeviceRepositoryModule = DeviceRepositoryModule;
exports.DeviceRepositoryModule = DeviceRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Device_1.Device])],
        providers: [device_repository_service_1.DeviceRepositoryService],
        exports: [device_repository_service_1.DeviceRepositoryService]
    })
], DeviceRepositoryModule);


/***/ }),
/* 84 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsFieldRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_params_field_repository_service_1 = __webpack_require__(35);
const typeorm_1 = __webpack_require__(22);
const DeviceParamsField_1 = __webpack_require__(36);
let DeviceParamsFieldRepositoryModule = class DeviceParamsFieldRepositoryModule {
};
exports.DeviceParamsFieldRepositoryModule = DeviceParamsFieldRepositoryModule;
exports.DeviceParamsFieldRepositoryModule = DeviceParamsFieldRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([DeviceParamsField_1.DeviceParamsField])],
        providers: [device_params_field_repository_service_1.DeviceParamsFieldRepositoryService],
        exports: [device_params_field_repository_service_1.DeviceParamsFieldRepositoryService]
    })
], DeviceParamsFieldRepositoryModule);


/***/ }),
/* 85 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_params_repository_service_1 = __webpack_require__(37);
const typeorm_1 = __webpack_require__(22);
const DeviceParams_1 = __webpack_require__(38);
let DeviceParamsRepositoryModule = class DeviceParamsRepositoryModule {
};
exports.DeviceParamsRepositoryModule = DeviceParamsRepositoryModule;
exports.DeviceParamsRepositoryModule = DeviceParamsRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([DeviceParams_1.DeviceParams])],
        providers: [device_params_repository_service_1.DeviceParamsRepositoryService],
        exports: [device_params_repository_service_1.DeviceParamsRepositoryService]
    })
], DeviceParamsRepositoryModule);


/***/ }),
/* 86 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RechargeOptionRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const recharge_option_repository_service_1 = __webpack_require__(45);
const RechargeOption_1 = __webpack_require__(46);
const typeorm_1 = __webpack_require__(22);
let RechargeOptionRepositoryModule = class RechargeOptionRepositoryModule {
};
exports.RechargeOptionRepositoryModule = RechargeOptionRepositoryModule;
exports.RechargeOptionRepositoryModule = RechargeOptionRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([RechargeOption_1.RechargeOption])],
        providers: [recharge_option_repository_service_1.RechargeOptionRepositoryService],
        exports: [recharge_option_repository_service_1.RechargeOptionRepositoryService]
    })
], RechargeOptionRepositoryModule);


/***/ }),
/* 87 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const sys_config_repository_service_1 = __webpack_require__(33);
const typeorm_1 = __webpack_require__(22);
const SysConfig_1 = __webpack_require__(34);
let SysConfigRepositoryModule = class SysConfigRepositoryModule {
};
exports.SysConfigRepositoryModule = SysConfigRepositoryModule;
exports.SysConfigRepositoryModule = SysConfigRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([SysConfig_1.SysConfig])],
        providers: [sys_config_repository_service_1.SysConfigRepositoryService],
        exports: [sys_config_repository_service_1.SysConfigRepositoryService]
    })
], SysConfigRepositoryModule);


/***/ }),
/* 88 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const water_bills_repository_service_1 = __webpack_require__(49);
const typeorm_1 = __webpack_require__(22);
const WaterBills_1 = __webpack_require__(50);
let WaterBillsRepositoryModule = class WaterBillsRepositoryModule {
};
exports.WaterBillsRepositoryModule = WaterBillsRepositoryModule;
exports.WaterBillsRepositoryModule = WaterBillsRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([WaterBills_1.WaterBills])],
        exports: [water_bills_repository_service_1.WaterBillsRepositoryService],
        providers: [water_bills_repository_service_1.WaterBillsRepositoryService]
    })
], WaterBillsRepositoryModule);


/***/ }),
/* 89 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const water_test_repository_service_1 = __webpack_require__(51);
const typeorm_1 = __webpack_require__(22);
const WaterTest_1 = __webpack_require__(52);
let WaterTestRepositoryModule = class WaterTestRepositoryModule {
};
exports.WaterTestRepositoryModule = WaterTestRepositoryModule;
exports.WaterTestRepositoryModule = WaterTestRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([WaterTest_1.WaterTest])],
        exports: [water_test_repository_service_1.WaterTestRepositoryService],
        providers: [water_test_repository_service_1.WaterTestRepositoryService]
    })
], WaterTestRepositoryModule);


/***/ }),
/* 90 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UserRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const user_repository_service_1 = __webpack_require__(47);
const User_1 = __webpack_require__(48);
const typeorm_1 = __webpack_require__(22);
let UserRepositoryModule = class UserRepositoryModule {
};
exports.UserRepositoryModule = UserRepositoryModule;
exports.UserRepositoryModule = UserRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([User_1.User])],
        providers: [user_repository_service_1.UserRepositoryService],
        exports: [user_repository_service_1.UserRepositoryService]
    })
], UserRepositoryModule);


/***/ }),
/* 91 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LoginModule = void 0;
const common_1 = __webpack_require__(3);
const login_service_1 = __webpack_require__(92);
const login_controller_1 = __webpack_require__(98);
const member_module_1 = __webpack_require__(15);
let LoginModule = class LoginModule {
};
exports.LoginModule = LoginModule;
exports.LoginModule = LoginModule = __decorate([
    (0, common_1.Module)({
        imports: [member_module_1.MemberModule],
        providers: [login_service_1.LoginService],
        controllers: [login_controller_1.LoginController]
    })
], LoginModule);


/***/ }),
/* 92 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d, _e;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LoginService = void 0;
const configure_1 = __webpack_require__(6);
const jwt_verify_1 = __webpack_require__(93);
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const member_service_1 = __webpack_require__(17);
const dayjs = __webpack_require__(59);
const cache_1 = __webpack_require__(53);
const LoginError_1 = __webpack_require__(97);
let LoginService = class LoginService {
    constructor(cache, db, jwt, config, memberService) {
        this.cache = cache;
        this.db = db;
        this.jwt = jwt;
        this.config = config;
        this.memberService = memberService;
        this.jwtExpire = 0;
        this.jwtExpire = Number(this.config.get('JWT_EXPIRE'));
    }
    async login(account, password, merchantName, ip) {
        let merchantId = 0;
        if (merchantName != null) {
            const merchant = await this.db.merchant.findOne({ name: merchantName }, ['id', 'enable']);
            if (merchant == null)
                throw new LoginError_1.default('商户不存在');
            if (!merchant.enable)
                throw new LoginError_1.default('账号已被禁用', 301);
            merchantId = merchant.id;
        }
        let time = dayjs().unix();
        let nextDayTime = dayjs(dayjs().format('YYYY-MM-DD')).add(1, 'day').unix();
        const loginFailMaxCount = Number(this.config.get('loginFailMaxCount'));
        const loginCountKey = 'login.er.' + merchantId + '.' + account + '.' + dayjs().format('YYMD');
        let loginCount = Number((await this.cache.get(loginCountKey)) || 0);
        if (loginCount >= loginFailMaxCount)
            throw new LoginError_1.default(`当然登陆失败次数已超过${loginFailMaxCount}次`);
        let lockKey = 'login.' + merchantId + '.' + account;
        const lock = await this.cache.set(lockKey, '', 10, 'NX');
        if (!lock)
            return null;
        const member = await this.db.member.findOne({ account: account, merchantId: merchantId }, ['name', 'password', 'id', 'salt', 'belong', 'canSuper', 'enable']);
        if (!member || this.memberService.buildPassword(password, member.salt) != member.password) {
            this.cache.del(lockKey);
            this.cache.set(loginCountKey, loginCount + 1, nextDayTime - time);
            throw new LoginError_1.default('账号或密码错误', 401, loginFailMaxCount - loginCount - 1);
        }
        if (!member.enable) {
            throw new LoginError_1.default('账号已被禁用', 301);
        }
        this.cache.del(lockKey);
        if (loginCount > 0) {
            this.cache.del(loginCountKey);
        }
        this.db.member.update({ id: member.id }, { lastLoginTime: time, lastIp: ip });
        return {
            name: member.name,
            super: member.canSuper,
            belong: member.belong,
            ...this.makeToken(member.id, time)
        };
    }
    makeToken(id, time) {
        if (!time) {
            time = Math.floor((new Date()).getTime() / 1000);
        }
        let payload = { key: id, id: Math.ceil((time - 1030) / 263), time: time };
        let accessToken = this.jwt.sign(payload, this.jwtExpire);
        return {
            accessToken,
            refreshToken: '1',
            expire: this.jwtExpire
        };
    }
};
exports.LoginService = LoginService;
exports.LoginService = LoginService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _a : Object, typeof (_b = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _b : Object, typeof (_c = typeof jwt_verify_1.JwtVerifyService !== "undefined" && jwt_verify_1.JwtVerifyService) === "function" ? _c : Object, typeof (_d = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _d : Object, typeof (_e = typeof member_service_1.MemberService !== "undefined" && member_service_1.MemberService) === "function" ? _e : Object])
], LoginService);


/***/ }),
/* 93 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(94), exports);
__exportStar(__webpack_require__(95), exports);


/***/ }),
/* 94 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JwtVerifyModule = void 0;
const common_1 = __webpack_require__(3);
const jwt_verify_service_1 = __webpack_require__(95);
const jwt_1 = __webpack_require__(96);
let JwtVerifyModule = class JwtVerifyModule {
};
exports.JwtVerifyModule = JwtVerifyModule;
exports.JwtVerifyModule = JwtVerifyModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [jwt_1.JwtModule.register({})],
        providers: [jwt_verify_service_1.JwtVerifyService],
        exports: [jwt_verify_service_1.JwtVerifyService],
    })
], JwtVerifyModule);


/***/ }),
/* 95 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JwtVerifyService = void 0;
const common_1 = __webpack_require__(3);
const jwt_1 = __webpack_require__(96);
let JwtVerifyService = class JwtVerifyService {
    constructor(jwtService) {
        this.jwtService = jwtService;
        this.secretLen = 15;
        this.pos = 5;
    }
    sign(payload, expire) {
        const secret = this.getRandomNChars(this.secretLen);
        let token = this.jwtService.sign(payload, {
            secret,
            expiresIn: expire
        });
        return this.mixUp(token, secret);
    }
    verify(token) {
        try {
            if (token === null)
                return null;
            const tokens = token.split(",");
            const tokenStr1 = tokens[1];
            const tokenStr2 = tokens[2];
            const str1 = tokenStr1.substring(this.pos, this.pos + this.pos + this.secretLen);
            tokens[1] = tokenStr1.substring(0, this.pos) + tokenStr1.substring(this.pos + this.pos + this.secretLen);
            tokens[2] = tokenStr2.substring(0, this.pos) + tokenStr2.substring(this.pos + this.pos);
            token = tokens.join(".");
            const secret = str1.substring(0, this.secretLen);
            return this.jwtService.verify(token, {
                secret
            });
        }
        catch (error) {
        }
        return null;
    }
    getRandomNChars(n) {
        const randomString = "1qwZYeX2rTtCSDFGHJKLy3m4V5uU6B7ioNp89aMRxvnASDFsdfgQh0WEjIkl";
        let characters = [...randomString];
        for (let i = characters.length - 1; i > 0; i--) {
            const j = Math.floor(Math.random() * (i + 1));
            [characters[i], characters[j]] = [characters[j], characters[i]];
        }
        const result = new Array(n).fill(null);
        for (let i = 0; i < n; i++) {
            const index = Math.floor(Math.random() * characters.length);
            result[i] = characters[index];
        }
        return result.join('');
    }
    mixUp(token, secret) {
        const str1 = secret + this.getRandomNChars(this.pos);
        const str2 = this.getRandomNChars(this.pos);
        const tokens = token.split('.');
        const tokenStr1 = tokens[1];
        const tokenStr2 = tokens[2];
        tokens[1] = tokenStr1.substring(0, this.pos) + str1 + tokenStr1.substring(this.pos);
        tokens[2] = tokenStr2.substring(0, this.pos) + str2 + tokenStr2.substring(this.pos);
        return tokens.join(',');
    }
};
exports.JwtVerifyService = JwtVerifyService;
exports.JwtVerifyService = JwtVerifyService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof jwt_1.JwtService !== "undefined" && jwt_1.JwtService) === "function" ? _a : Object])
], JwtVerifyService);


/***/ }),
/* 96 */
/***/ ((module) => {

module.exports = require("@nestjs/jwt");

/***/ }),
/* 97 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
class LoginErro extends Error {
    constructor(message, code = 0, count = 0) {
        super(message);
        this.code = code;
        this.count = count;
    }
}
exports["default"] = LoginErro;


/***/ }),
/* 98 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LoginController = void 0;
const common_1 = __webpack_require__(3);
const common_2 = __webpack_require__(99);
const login_service_1 = __webpack_require__(92);
const response_util_1 = __webpack_require__(62);
let LoginController = class LoginController {
    constructor(service) {
        this.service = service;
    }
    async login(dto, ip) {
        try {
            const r = await this.service.login(dto.account, dto.password, null, ip);
            return response_util_1.ResponseUtilService.successRes(r);
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message, { code: error.code, data: error.count });
        }
    }
};
exports.LoginController = LoginController;
__decorate([
    (0, common_1.Post)(),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, common_1.Ip)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof common_2.CommonDto !== "undefined" && common_2.CommonDto) === "function" ? _b : Object, String]),
    __metadata("design:returntype", Promise)
], LoginController.prototype, "login", null);
exports.LoginController = LoginController = __decorate([
    (0, common_1.Controller)('login'),
    __metadata("design:paramtypes", [typeof (_a = typeof login_service_1.LoginService !== "undefined" && login_service_1.LoginService) === "function" ? _a : Object])
], LoginController);


/***/ }),
/* 99 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CommonDto = void 0;
const class_validator_1 = __webpack_require__(68);
class CommonDto {
}
exports.CommonDto = CommonDto;
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsNotEmpty)({ message: '请输入登录账号' }),
    __metadata("design:type", String)
], CommonDto.prototype, "account", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsNotEmpty)({ message: '请输入登录密码' }),
    __metadata("design:type", String)
], CommonDto.prototype, "password", void 0);


/***/ }),
/* 100 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MenuModule = void 0;
const common_1 = __webpack_require__(3);
const menu_service_1 = __webpack_require__(101);
const menu_controller_1 = __webpack_require__(102);
const member_module_1 = __webpack_require__(15);
let MenuModule = class MenuModule {
};
exports.MenuModule = MenuModule;
exports.MenuModule = MenuModule = __decorate([
    (0, common_1.Module)({
        imports: [member_module_1.MemberModule],
        providers: [menu_service_1.MenuService],
        controllers: [menu_controller_1.MenuController]
    })
], MenuModule);


/***/ }),
/* 101 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MenuService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const member_service_1 = __webpack_require__(17);
let MenuService = class MenuService {
    constructor(db, memberService) {
        this.db = db;
        this.memberService = memberService;
    }
    async add(dto) {
        if (true == await this.db.menu.isExistsByWhere({ name: dto.name, parentId: dto.parentId }))
            throw new Error('已存在相同的名称');
        if ((dto.type === 'FOLD' || dto.type === 'PAGE') && true == await this.db.menu.isExistsByWhere({ path: dto.path, parentId: dto.parentId }))
            throw new Error('已存在相同的路径');
        if (dto.type === 'BUTTON') {
            delete dto.component;
            delete dto.display;
            delete dto.path;
            delete dto.keepAlive;
            delete dto.sort;
        }
        return this.db.menu.insert(dto);
    }
    async update(dto) {
        let fields = Object.keys(dto);
        if (fields.length == 0)
            return true;
        fields.push('parentId');
        const row = await this.db.menu.findOne({ id: dto.id }, fields);
        if (!row)
            return;
        let updateData = {};
        const parentId = row.parentId;
        delete row.parentId;
        for (let k in row) {
            if (k in dto) {
                if (row[k] != dto[k]) {
                    updateData[k] = dto[k];
                }
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.name && (true == await this.db.menu.isExistsByWhere({ name: updateData.name, parentId: parentId })))
            throw new Error('已存在相同的名称');
        if (updateData.path && (true == await this.db.menu.isExistsByWhere({ path: updateData.path, parentId: parentId })))
            throw new Error('已存在相同的路径');
        return this.db.menu.update({ id: dto.id }, updateData);
    }
    async del(id) {
        if ((await this.db.menu.isExistsByWhere({ parentId: id })))
            throw new Error('该菜单存在子菜单，不可删除');
        return this.db.menu.delete({ id: id });
    }
    async availableMenu(memberId) {
        const menus = await this.memberService.permissionMenu(memberId, null);
        return menus.filter(v => v.enable);
    }
    async list(memberId) {
        const menus = await this.memberService.permissionMenu(memberId, null);
        return menus;
    }
};
exports.MenuService = MenuService;
exports.MenuService = MenuService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof member_service_1.MemberService !== "undefined" && member_service_1.MemberService) === "function" ? _b : Object])
], MenuService);


/***/ }),
/* 102 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MenuController = void 0;
const common_1 = __webpack_require__(3);
const menu_service_1 = __webpack_require__(101);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(103);
const update_dto_1 = __webpack_require__(104);
let MenuController = class MenuController {
    constructor(service) {
        this.service = service;
    }
    async add(dto) {
        try {
            const r = await this.service.add(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async permission(req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        const menus = await this.service.availableMenu(memberId);
        return response_util_1.ResponseUtilService.successRes(menus);
    }
    async list(req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        const menus = await this.service.list(memberId);
        return response_util_1.ResponseUtilService.successRes(menus);
    }
};
exports.MenuController = MenuController;
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _b : Object]),
    __metadata("design:returntype", Promise)
], MenuController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _c : Object]),
    __metadata("design:returntype", Promise)
], MenuController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], MenuController.prototype, "del", null);
__decorate([
    (0, common_1.Get)('permission'),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], MenuController.prototype, "permission", null);
__decorate([
    (0, common_1.Get)('list'),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], MenuController.prototype, "list", null);
exports.MenuController = MenuController = __decorate([
    (0, common_1.Controller)('menu'),
    __metadata("design:paramtypes", [typeof (_a = typeof menu_service_1.MenuService !== "undefined" && menu_service_1.MenuService) === "function" ? _a : Object])
], MenuController);


/***/ }),
/* 103 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsNotEmpty)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(10),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "type", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(50),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "path", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(50),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "component", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(100),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "permission", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(100),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "api", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(10),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "apiMethod", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "keepAlive", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "display", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "sort", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "parentId", void 0);


/***/ }),
/* 104 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(103);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 105 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RoleModule = void 0;
const common_1 = __webpack_require__(3);
const role_service_1 = __webpack_require__(106);
const role_controller_1 = __webpack_require__(107);
let RoleModule = class RoleModule {
};
exports.RoleModule = RoleModule;
exports.RoleModule = RoleModule = __decorate([
    (0, common_1.Module)({
        providers: [role_service_1.RoleService],
        controllers: [role_controller_1.RoleController]
    })
], RoleModule);


/***/ }),
/* 106 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RoleService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const dayjs = __webpack_require__(59);
let RoleService = class RoleService {
    constructor(db) {
        this.db = db;
    }
    async options(memberId) {
        return this.db.role.find({ creatorId: memberId, enable: true }, { id: true, name: true });
    }
    async page(dto, memberId) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {
            creatorId: memberId
        };
        result.total = await this.db.role.count(where);
        if (result.total > 0) {
            result.rows = await this.db.role.pagination(dto.pageNo, dto.pageSize, where, null, { sort: 'DESC', id: 'DESC' });
        }
        return result;
    }
    async add(dto, memberId) {
        if (true == await this.db.role.isExistsByWhere({ name: dto.name, creatorId: memberId }))
            throw new Error('已存在相同的名称');
        return this.db.role.insert({ ...dto, creatorId: memberId, createTime: dayjs().unix() });
    }
    async update(dto, memberId) {
        let fields = Object.keys(dto);
        if (fields.length == 0)
            return true;
        const row = await this.db.role.findOne({ id: dto.id });
        if (!row || row.creatorId != memberId)
            return false;
        let updateData = {};
        delete row.creatorId;
        for (let k in row) {
            if (k in dto) {
                if (k == 'menus') {
                    if (row[k] && dto[k]) {
                        const m1 = [...row[k]];
                        const m2 = [...dto[k]];
                        m1.sort();
                        m2.sort();
                        if (JSON.stringify(m1) == JSON.stringify(m2))
                            continue;
                    }
                }
                else {
                    if (row[k] == dto[k])
                        continue;
                }
                updateData[k] = dto[k];
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.name && (true == await this.db.role.isExistsByWhere({ name: updateData.name, creatorId: memberId })))
            throw new Error('已存在相同的名称');
        return this.db.role.update({ id: dto.id }, updateData);
    }
    async del(id, memberId) {
        let role = await this.db.role.findOne({ id }, ['creatorId']);
        if (!role || role.creatorId != memberId)
            return;
        return this.db.role.delete({ id: id });
    }
};
exports.RoleService = RoleService;
exports.RoleService = RoleService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], RoleService);


/***/ }),
/* 107 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RoleController = void 0;
const common_1 = __webpack_require__(3);
const role_service_1 = __webpack_require__(106);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(108);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
const update_dto_1 = __webpack_require__(109);
const page_dto_1 = __webpack_require__(110);
let RoleController = class RoleController {
    constructor(service) {
        this.service = service;
    }
    async options(req) {
        const result = await this.service.options(req[constant_1.ReqAttrs.MEMBER_ID]);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async page(dto, req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        const result = await this.service.page(dto, memberId);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async add(dto, req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        try {
            const r = await this.service.add(dto, memberId);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto, req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        try {
            const r = await this.service.update(dto, memberId);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id, req) {
        if (id < 1)
            return null;
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        try {
            const r = await this.service.del(id, memberId);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.RoleController = RoleController;
__decorate([
    (0, common_1.Get)('options'),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], RoleController.prototype, "options", null);
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], RoleController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _c : Object, Object]),
    __metadata("design:returntype", Promise)
], RoleController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_d = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _d : Object, Object]),
    __metadata("design:returntype", Promise)
], RoleController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], RoleController.prototype, "del", null);
exports.RoleController = RoleController = __decorate([
    (0, common_1.Controller)('role'),
    __metadata("design:paramtypes", [typeof (_a = typeof role_service_1.RoleService !== "undefined" && role_service_1.RoleService) === "function" ? _a : Object])
], RoleController);


/***/ }),
/* 108 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", typeof (_a = typeof Array !== "undefined" && Array) === "function" ? _a : Object)
], CreateDto.prototype, "menus", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(100),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "remark", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)({}),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)({}),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "sort", void 0);


/***/ }),
/* 109 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(108);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 110 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "name", void 0);


/***/ }),
/* 111 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AuthGuard = void 0;
const jwt_verify_1 = __webpack_require__(93);
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const configure_1 = __webpack_require__(6);
const constant_1 = __webpack_require__(61);
let AuthGuard = class AuthGuard {
    async canActivate(context) {
        let request = context.switchToHttp().getRequest();
        const route = request.route;
        let path = route.path;
        const white = this.config.get('white');
        const routePrefix = this.config.get('apiPrefix');
        if (routePrefix != undefined && routePrefix.length > 0) {
            path = path.substring(routePrefix.length + 1);
        }
        const token = request.headers.authorization;
        if (!white.includes(path) && !token)
            return false;
        if (token) {
            const payload = this.jwt.verify(token);
            if (!payload)
                return false;
            const memberId = payload.key;
            const member = await this.db.member.findOne({ id: memberId }, ['enable', 'roles', 'canSuper', 'belong', 'merchantId']);
            if (!member || member.enable == false)
                return false;
            if (member.canSuper == false) {
            }
            else { }
            member.id = memberId;
            request[constant_1.ReqAttrs.BELONG] = member.belong;
            request[constant_1.ReqAttrs.MEMBER_ID] = memberId;
            request[constant_1.ReqAttrs.IS_SUPER] = member.canSuper;
            request[constant_1.ReqAttrs.MERCHANT_ID] = member.merchantId;
        }
        request.locale = request.headers.locale;
        return true;
    }
};
exports.AuthGuard = AuthGuard;
__decorate([
    (0, common_1.Inject)(),
    __metadata("design:type", typeof (_a = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _a : Object)
], AuthGuard.prototype, "config", void 0);
__decorate([
    (0, common_1.Inject)(),
    __metadata("design:type", typeof (_b = typeof jwt_verify_1.JwtVerifyService !== "undefined" && jwt_verify_1.JwtVerifyService) === "function" ? _b : Object)
], AuthGuard.prototype, "jwt", void 0);
__decorate([
    (0, common_1.Inject)(),
    __metadata("design:type", typeof (_c = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _c : Object)
], AuthGuard.prototype, "db", void 0);
exports.AuthGuard = AuthGuard = __decorate([
    (0, common_1.Injectable)()
], AuthGuard);


/***/ }),
/* 112 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryCategoryModule = void 0;
const common_1 = __webpack_require__(3);
const dictionary_category_controller_1 = __webpack_require__(113);
const dictionary_category_service_1 = __webpack_require__(114);
let DictionaryCategoryModule = class DictionaryCategoryModule {
};
exports.DictionaryCategoryModule = DictionaryCategoryModule;
exports.DictionaryCategoryModule = DictionaryCategoryModule = __decorate([
    (0, common_1.Module)({
        controllers: [dictionary_category_controller_1.DictionaryCategoryController],
        providers: [dictionary_category_service_1.DictionaryCategoryService]
    })
], DictionaryCategoryModule);


/***/ }),
/* 113 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryCategoryController = void 0;
const common_1 = __webpack_require__(3);
const dictionary_category_service_1 = __webpack_require__(114);
const response_util_1 = __webpack_require__(62);
const create_dto_1 = __webpack_require__(115);
const dto_pipe_1 = __webpack_require__(65);
const update_dto_1 = __webpack_require__(116);
let DictionaryCategoryController = class DictionaryCategoryController {
    constructor(service) {
        this.service = service;
    }
    async items() {
        const res = await this.service.items();
        return response_util_1.ResponseUtilService.successRes(res);
    }
    async add(dto) {
        try {
            const r = await this.service.add(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.DictionaryCategoryController = DictionaryCategoryController;
__decorate([
    (0, common_1.Get)('items'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], DictionaryCategoryController.prototype, "items", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _b : Object]),
    __metadata("design:returntype", Promise)
], DictionaryCategoryController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _c : Object]),
    __metadata("design:returntype", Promise)
], DictionaryCategoryController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], DictionaryCategoryController.prototype, "del", null);
exports.DictionaryCategoryController = DictionaryCategoryController = __decorate([
    (0, common_1.Controller)('dictionary/category'),
    __metadata("design:paramtypes", [typeof (_a = typeof dictionary_category_service_1.DictionaryCategoryService !== "undefined" && dictionary_category_service_1.DictionaryCategoryService) === "function" ? _a : Object])
], DictionaryCategoryController);


/***/ }),
/* 114 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryCategoryService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
let DictionaryCategoryService = class DictionaryCategoryService {
    constructor(db) {
        this.db = db;
    }
    async items() {
        const res = {
            categorys: [],
            items: []
        };
        res.categorys = await this.db.dictionaryCategory.find();
        res.items = await this.db.dictionaryItem.find();
        return res;
    }
    async add(dto) {
        if ((await this.db.dictionaryCategory.isExistsByWhere({ name: dto.name })))
            throw new Error('已存在相同的名称');
        if ((await this.db.dictionaryCategory.isExistsByWhere({ code: dto.code })))
            throw new Error('已存在相同的编码');
        return this.db.dictionaryCategory.insert(dto);
    }
    async update(dto) {
        const category = await this.db.dictionaryCategory.findOne({ id: dto.id });
        if (!category)
            return false;
        let updateData = {};
        if (category.name != dto.name) {
            updateData.name = dto.name;
        }
        if (category.code.toLocaleLowerCase() != dto.code.toLocaleLowerCase()) {
            updateData.code = dto.code;
        }
        if ((Object.keys(updateData)).length == 0)
            return true;
        if (updateData.name && (await this.db.dictionaryCategory.isExistsByWhere({ name: dto.name })))
            throw new Error('已存在相同的名称');
        if (updateData.code && (await this.db.dictionaryCategory.isExistsByWhere({ code: dto.code })))
            throw new Error('已存在相同的编码');
        return this.db.dictionaryCategory.update({ id: dto.id }, dto);
    }
    async del(id) {
        if ((await this.db.dictionaryItem.isExistsByWhere({ categoryId: id })))
            throw new Error('该分类存在子分类，不可删除');
        return this.db.dictionaryCategory.delete({ id: id });
    }
};
exports.DictionaryCategoryService = DictionaryCategoryService;
exports.DictionaryCategoryService = DictionaryCategoryService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], DictionaryCategoryService);


/***/ }),
/* 115 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.Length)(1, 30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.Length)(1, 20),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "code", void 0);


/***/ }),
/* 116 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(115);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 117 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryItemModule = void 0;
const common_1 = __webpack_require__(3);
const dictionary_item_service_1 = __webpack_require__(118);
const dictionary_item_controller_1 = __webpack_require__(119);
let DictionaryItemModule = class DictionaryItemModule {
};
exports.DictionaryItemModule = DictionaryItemModule;
exports.DictionaryItemModule = DictionaryItemModule = __decorate([
    (0, common_1.Module)({
        providers: [dictionary_item_service_1.DictionaryItemService],
        controllers: [dictionary_item_controller_1.DictionaryItemController]
    })
], DictionaryItemModule);


/***/ }),
/* 118 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryItemService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
let DictionaryItemService = class DictionaryItemService {
    constructor(db) {
        this.db = db;
    }
    async add(dto) {
        if ((await this.db.dictionaryItem.isExistsByWhere({ name: dto.name, categoryId: dto.categoryId, parentId: dto.parentId })))
            throw new Error('已存在相同的名称');
        if ((await this.db.dictionaryItem.isExistsByWhere({ code: dto.code, categoryId: dto.categoryId, parentId: dto.parentId })))
            throw new Error('已存在相同的编码');
        return this.db.dictionaryItem.insert(dto);
    }
    async update(dto) {
        const item = await this.db.dictionaryItem.findOne({ id: dto.id });
        if (!item)
            return false;
        let updateData = {};
        if (item.name != dto.name) {
            updateData.name = dto.name;
        }
        if (item.code.toLocaleLowerCase() != dto.code.toLocaleLowerCase()) {
            updateData.code = dto.code;
        }
        if ((Object.keys(updateData)).length == 0)
            return true;
        if (updateData.name && (await this.db.dictionaryItem.isExistsByWhere({ name: dto.name })))
            throw new Error('已存在相同的名称');
        if (updateData.code && (await this.db.dictionaryItem.isExistsByWhere({ code: dto.code })))
            throw new Error('已存在相同的编码');
        return this.db.dictionaryItem.update({ id: dto.id }, dto);
    }
    async del(id) {
        if ((await this.db.dictionaryItem.isExistsByWhere({ categoryId: id })))
            throw new Error('该分类存在子分类，不可删除');
        return this.db.dictionaryItem.delete({ id: id });
    }
    async getItemByCategory(categoryCode) {
        const category = await this.db.dictionaryCategory.findOne({ code: categoryCode }, ['id']);
        if (!category)
            return [];
        return this.db.dictionaryItem.find({ categoryId: category.id });
    }
    async getItemCodeToNameByCategory(categoryCode) {
        const map = {};
        const items = await this.getItemByCategory(categoryCode);
        items.forEach(item => {
            map[item.code] = item.name;
        });
        return map;
    }
    async getItemNameToCodeByCategory(categoryCode) {
        const map = {};
        const items = await this.getItemByCategory(categoryCode);
        items.forEach(item => {
            map[item.name] = item.code;
        });
        return map;
    }
};
exports.DictionaryItemService = DictionaryItemService;
exports.DictionaryItemService = DictionaryItemService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], DictionaryItemService);


/***/ }),
/* 119 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DictionaryItemController = void 0;
const common_1 = __webpack_require__(3);
const dictionary_item_service_1 = __webpack_require__(118);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(120);
const response_util_1 = __webpack_require__(62);
const update_dto_1 = __webpack_require__(121);
let DictionaryItemController = class DictionaryItemController {
    constructor(service) {
        this.service = service;
    }
    async add(dto) {
        try {
            const r = await this.service.add(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async items(category) {
        const items = await this.service.getItemByCategory(category);
        return response_util_1.ResponseUtilService.successRes(items);
    }
};
exports.DictionaryItemController = DictionaryItemController;
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _b : Object]),
    __metadata("design:returntype", Promise)
], DictionaryItemController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _c : Object]),
    __metadata("design:returntype", Promise)
], DictionaryItemController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], DictionaryItemController.prototype, "del", null);
__decorate([
    (0, common_1.Get)(':category'),
    __param(0, (0, common_1.Param)('category')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], DictionaryItemController.prototype, "items", null);
exports.DictionaryItemController = DictionaryItemController = __decorate([
    (0, common_1.Controller)('dictionary/item'),
    __metadata("design:paramtypes", [typeof (_a = typeof dictionary_item_service_1.DictionaryItemService !== "undefined" && dictionary_item_service_1.DictionaryItemService) === "function" ? _a : Object])
], DictionaryItemController);


/***/ }),
/* 120 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsNumber)(),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "parentId", void 0);
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    (0, class_validator_1.IsNotEmpty)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "categoryId", void 0);
__decorate([
    (0, class_validator_1.Length)(1, 30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.Length)(1, 20),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "code", void 0);


/***/ }),
/* 121 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(120);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 122 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MerchantModule = void 0;
const common_1 = __webpack_require__(3);
const merchant_service_1 = __webpack_require__(123);
const merchant_controller_1 = __webpack_require__(124);
const member_module_1 = __webpack_require__(15);
let MerchantModule = class MerchantModule {
};
exports.MerchantModule = MerchantModule;
exports.MerchantModule = MerchantModule = __decorate([
    (0, common_1.Module)({
        imports: [member_module_1.MemberModule],
        providers: [merchant_service_1.MerchantService],
        controllers: [merchant_controller_1.MerchantController]
    })
], MerchantModule);


/***/ }),
/* 123 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d, _e;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MerchantService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const cache_1 = __webpack_require__(53);
const typeorm_1 = __webpack_require__(23);
const dayjs = __webpack_require__(59);
const Merchant_1 = __webpack_require__(44);
const Member_1 = __webpack_require__(28);
const member_service_1 = __webpack_require__(17);
const configure_1 = __webpack_require__(6);
const work_exception_1 = __webpack_require__(60);
const constant_1 = __webpack_require__(61);
let MerchantService = class MerchantService {
    constructor(db, cache, memberService, config, dataSource) {
        this.db = db;
        this.cache = cache;
        this.memberService = memberService;
        this.config = config;
        this.dataSource = dataSource;
    }
    async page(dto, memberId) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {};
        if (dto.name) {
            where.name = dto.name;
        }
        result.total = await this.db.merchant.count(where);
        if (result.total > 0) {
            result.rows = await this.db.merchant.pagination(dto.pageNo, dto.pageSize, where, null, { id: 'DESC' });
            if (result.rows.length > 0) {
                const memberIds = result.rows.map(row => row.adminId);
                const members = await this.db.member.find({ id: (0, typeorm_1.In)(memberIds) }, { id: true, account: true, roles: true, name: true });
                result.rows.forEach(row => {
                    const member = members.find(v => v.id == row.adminId);
                    row.admin = member;
                });
            }
        }
        return result;
    }
    async add(dto, memberId, merchantId) {
        const profitRate = dto.profitRate;
        if (profitRate < 0 || profitRate > 1)
            return false;
        const lockKey = 'c:m:' + dto.name;
        const lock = await this.cache.set(lockKey, '1', 10, 'NX');
        if (!lock || (await this.db.merchant.isExistsByWhere({ name: dto.name })))
            throw new work_exception_1.default('已存在相同的名称');
        const time = dayjs().unix();
        const merchant = {
            profitRate: String(profitRate),
            name: dto.name,
            createTime: time,
            creatorId: memberId,
            parentId: merchantId,
        };
        if (dto.tel) {
            merchant.tel = dto.tel;
        }
        if (dto.enable) {
            merchant.enable = dto.enable;
        }
        if (dto.tel) {
            merchant.tel = dto.tel;
        }
        const member = {
            account: dto.adminAccount,
            createTime: time,
            salt: this.memberService.generateSalt(),
            creatorId: memberId,
            belong: constant_1.MemberBelong.MERCHANT
        };
        if (dto.enable) {
            member.enable = dto.enable;
        }
        member.password = this.memberService.buildPassword(dto.adminPassword || this.config.get('memberDefaultPassword'), member.salt);
        if (dto.adminName) {
            member.name = dto.adminName;
        }
        if (dto.roles) {
            member.roles = dto.roles;
        }
        const queryRunner = this.dataSource.createQueryRunner();
        await queryRunner.connect();
        await queryRunner.startTransaction();
        try {
            const r1 = await queryRunner.manager.insert(Merchant_1.Merchant, merchant);
            member.merchantId = r1.raw.insertId;
            const r2 = await queryRunner.manager.insert(Member_1.Member, member);
            await queryRunner.manager.update(Merchant_1.Merchant, { id: member.merchantId }, { adminId: r2.raw.insertId });
            await queryRunner.commitTransaction();
            return true;
        }
        catch (err) {
            await queryRunner.rollbackTransaction();
        }
        finally {
            this.cache.del(lockKey);
            await queryRunner.release();
        }
        return false;
    }
    async update(dto) {
        const id = dto.id;
        const row = await this.db.merchant.findOne({ id: id }, { adminId: true, name: true, profitRate: true, tel: true, enable: true });
        if (!row)
            return false;
        const updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (dto[k] != row[k]) {
                    updateData[k] = dto[k];
                }
            }
        }
        if (updateData.name) {
            if ((await this.db.merchant.isExistsByWhere({ name: updateData.name })))
                throw new work_exception_1.default('已存在相同的名称');
        }
        if (Object.keys(updateData).length > 0 || dto.roles != undefined) {
            const queryRunner = this.dataSource.createQueryRunner();
            await queryRunner.connect();
            await queryRunner.startTransaction();
            try {
                if (Object.keys(updateData).length > 0) {
                    await queryRunner.manager.update(Merchant_1.Merchant, { id }, updateData);
                }
                if (dto.roles != undefined) {
                    await queryRunner.manager.update(Member_1.Member, { id: row.adminId }, { roles: dto.roles });
                }
                await queryRunner.commitTransaction();
                return true;
            }
            catch (err) {
                await queryRunner.rollbackTransaction();
            }
            finally {
                await queryRunner.release();
            }
            return false;
        }
        return true;
    }
    async del(id) {
        let row = await this.db.merchant.findOne({ id }, ['id']);
        if (!row)
            return false;
        return this.db.merchant.delete({ id: id });
    }
    async resetPwd(id, password) {
        let row = await this.db.merchant.findOne({ id }, ['id', 'adminId']);
        if (!row)
            return false;
        const member = await this.db.member.findOne({ id: row.adminId }, { password: true, salt: true });
        if (this.memberService.buildPassword(password, member.salt) == member.password)
            throw new work_exception_1.default('密码不能和旧密码一样');
        member.salt = this.memberService.generateSalt();
        member.password = this.memberService.buildPassword(password, member.salt);
        return this.db.member.update({ id: row.adminId }, member);
    }
    async queryMerchantByName(name, merchantId) {
        return this.db.merchant.find({ parentId: merchantId, name: (0, typeorm_1.Like)('%' + name + '%') });
    }
};
exports.MerchantService = MerchantService;
exports.MerchantService = MerchantService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _b : Object, typeof (_c = typeof member_service_1.MemberService !== "undefined" && member_service_1.MemberService) === "function" ? _c : Object, typeof (_d = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _d : Object, typeof (_e = typeof typeorm_1.DataSource !== "undefined" && typeorm_1.DataSource) === "function" ? _e : Object])
], MerchantService);


/***/ }),
/* 124 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d, _e;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MerchantController = void 0;
const common_1 = __webpack_require__(3);
const merchant_service_1 = __webpack_require__(123);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(125);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
const update_dto_1 = __webpack_require__(126);
const page_dto_1 = __webpack_require__(127);
const resetpwd_dto_1 = __webpack_require__(128);
let MerchantController = class MerchantController {
    constructor(service) {
        this.service = service;
    }
    async page(dto, req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        const result = await this.service.page(dto, memberId);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async add(dto, req) {
        try {
            const r = await this.service.add(dto, req[constant_1.ReqAttrs.MEMBER_ID], req[constant_1.ReqAttrs.MERCHANT_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async resetpwd(dto) {
        try {
            const r = await this.service.resetPwd(dto.id, dto.password);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async queryMerchantByName(req, name) {
        console.log(req[constant_1.ReqAttrs.MERCHANT_ID]);
        const rows = await this.service.queryMerchantByName(name, req[constant_1.ReqAttrs.MERCHANT_ID]);
        return response_util_1.ResponseUtilService.successRes(rows);
    }
};
exports.MerchantController = MerchantController;
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], MerchantController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _c : Object, Object]),
    __metadata("design:returntype", Promise)
], MerchantController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_d = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _d : Object]),
    __metadata("design:returntype", Promise)
], MerchantController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], MerchantController.prototype, "del", null);
__decorate([
    (0, common_1.Put)('resetpwd'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_e = typeof resetpwd_dto_1.default !== "undefined" && resetpwd_dto_1.default) === "function" ? _e : Object]),
    __metadata("design:returntype", Promise)
], MerchantController.prototype, "resetpwd", null);
__decorate([
    (0, common_1.Get)("query"),
    __param(0, (0, common_1.Req)()),
    __param(1, (0, common_1.Query)('name')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", Promise)
], MerchantController.prototype, "queryMerchantByName", null);
exports.MerchantController = MerchantController = __decorate([
    (0, common_1.Controller)('merchant'),
    __metadata("design:paramtypes", [typeof (_a = typeof merchant_service_1.MerchantService !== "undefined" && merchant_service_1.MerchantService) === "function" ? _a : Object])
], MerchantController);


/***/ }),
/* 125 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(11),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "tel", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "adminName", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "adminAccount", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "adminPassword", void 0);
__decorate([
    (0, class_validator_1.Max)(1),
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "profitRate", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(100),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "remark", void 0);
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Array)
], CreateDto.prototype, "roles", void 0);


/***/ }),
/* 126 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(125);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 127 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "name", void 0);


/***/ }),
/* 128 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class ResetPwdDto {
}
exports["default"] = ResetPwdDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], ResetPwdDto.prototype, "id", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], ResetPwdDto.prototype, "password", void 0);


/***/ }),
/* 129 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeModule = void 0;
const common_1 = __webpack_require__(3);
const device_type_service_1 = __webpack_require__(130);
const device_type_controller_1 = __webpack_require__(131);
let DeviceTypeModule = class DeviceTypeModule {
};
exports.DeviceTypeModule = DeviceTypeModule;
exports.DeviceTypeModule = DeviceTypeModule = __decorate([
    (0, common_1.Module)({
        providers: [device_type_service_1.DeviceTypeService],
        exports: [device_type_service_1.DeviceTypeService],
        controllers: [device_type_controller_1.DeviceTypeController]
    })
], DeviceTypeModule);


/***/ }),
/* 130 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const DeviceType_1 = __webpack_require__(42);
const dayjs = __webpack_require__(59);
const work_exception_1 = __webpack_require__(60);
const typeorm_1 = __webpack_require__(23);
let DeviceTypeService = class DeviceTypeService {
    constructor(db, dataSource) {
        this.db = db;
        this.dataSource = dataSource;
    }
    async list() {
        return this.db.deviceType.find(null, null, null, null, { sort: 'DESC', id: 'DESC' });
    }
    async options() {
        return this.db.deviceType.find({ enable: true }, { id: true, name: true, code: true, aliProduct: true, level: true, parentId: true }, null, null, { sort: 'DESC', id: 'DESC' });
    }
    async add(dto, memberId) {
        if (true == await this.db.deviceType.isExistsByWhere({ name: dto.name, parentId: dto.parentId }))
            throw new Error('已存在相同的名称');
        if (true == await this.db.deviceType.isExistsByWhere({ code: dto.code, parentId: dto.parentId }))
            throw new Error('已存在相同的编码');
        const data = {
            ...dto
        };
        if (dto.parentId > 0) {
            const parent = await this.db.deviceType.findOne({ id: dto.parentId }, { level: true, topId: true });
            if (!parent)
                return false;
            data.level = parent.level + 1;
            data.topId = parent.topId == 0 ? dto.parentId : parent.topId;
        }
        console.log(data);
        data.createTime = dayjs().unix();
        data.creatorId = memberId;
        return this.db.deviceType.insert(data);
    }
    async update(dto) {
        let fields = Object.keys(dto);
        if (fields.length == 0)
            return true;
        const row = await this.db.deviceType.findOne({ id: dto.id });
        if (!row)
            return false;
        let updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (row[k] != dto[k]) {
                    updateData[k] = dto[k];
                }
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.name && (true == await this.db.deviceType.isExistsByWhere({ name: updateData.name, parentId: dto.parentId == undefined ? row.parentId : dto.parentId })))
            throw new Error('已存在相同的名称');
        if (updateData.code && (true == await this.db.deviceType.isExistsByWhere({ code: updateData.code, parentId: dto.parentId == undefined ? row.parentId : dto.parentId })))
            throw new Error('已存在相同的编码');
        updateData.updateTime = dayjs().unix();
        if (updateData.parentId != undefined && updateData.parentId != row.parentId) {
            let newTopId = 0;
            let level = 0;
            if (updateData.parentId == 0) {
                updateData.topId = 0;
                newTopId = row.id;
                updateData.level = 0;
                level = 0 - row.level;
            }
            else {
                const newParent = await this.db.deviceType.findOne({ id: dto.parentId }, { id: true, topId: true, level: true });
                if (!newParent)
                    return false;
                newTopId = newParent.topId == 0 ? newParent.id : newParent.topId;
                updateData.topId = newTopId;
                updateData.level = newParent.level + 1;
                level = updateData.level - row.level;
            }
            const subRows = await this.db.deviceType.find({ topId: row.parentId == 0 ? dto.id : row.topId });
            if (subRows.length > 0) {
                const subIds = [];
                this.querySubCategory(subRows, subIds, dto.id);
                if (updateData.parentId == dto.id || subIds.includes(dto.parentId))
                    throw new work_exception_1.default('请选择正确的上级类型');
                if (subIds.length > 0) {
                    const queryRunner = this.dataSource.createQueryRunner();
                    await queryRunner.connect();
                    await queryRunner.startTransaction();
                    try {
                        const r1 = await queryRunner.manager.update(DeviceType_1.DeviceType, { id: dto.id }, updateData);
                        if (r1.affected < 1) {
                            console.log('更改类型失败');
                            await queryRunner.rollbackTransaction();
                            return false;
                        }
                        const update = {
                            topId: newTopId
                        };
                        if (level > 0) {
                            update.level = () => ("`level` + " + level);
                        }
                        else if (level < 0) {
                            update.level = () => ("`level` " + level);
                        }
                        const r2 = await queryRunner.manager.update(DeviceType_1.DeviceType, { id: (0, typeorm_1.In)(subIds) }, update);
                        if (r2.affected < 1) {
                            console.log('更改子分类失败');
                            await queryRunner.rollbackTransaction();
                            return false;
                        }
                        await queryRunner.commitTransaction();
                        return true;
                    }
                    catch (err) {
                        await queryRunner.rollbackTransaction();
                    }
                    finally {
                        await queryRunner.release();
                    }
                    return false;
                }
            }
        }
        const r = await this.db.deviceType.update({ id: dto.id }, updateData);
        return r > 0;
    }
    async del(id) {
        if ((await this.db.deviceType.isExistsByWhere({ parentId: id })))
            throw new Error('该类型存在子类型，不可删除');
        return this.db.deviceType.delete({ id: id });
    }
    querySubCategory(categories, ids, pid) {
        categories.forEach(cate => {
            if (cate.parentId == pid) {
                ids.push(cate.id);
                this.querySubCategory(categories, ids, cate.id);
            }
        });
    }
    async paramsField(id) {
        const deviceType = await this.db.deviceType.findOne({ id }, ['id', 'paramFields']);
        if (!deviceType || !deviceType.paramFields || deviceType.paramFields.length == 0)
            return null;
        const rows = await this.db.deviceParamsField.find({ id: (0, typeorm_1.In)(deviceType.paramFields) }, { id: true, key: true, name: true, inputType: true, unit: true, options: () => true, enable: true });
        return rows.filter(row => row.enable);
    }
};
exports.DeviceTypeService = DeviceTypeService;
exports.DeviceTypeService = DeviceTypeService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof typeorm_1.DataSource !== "undefined" && typeorm_1.DataSource) === "function" ? _b : Object])
], DeviceTypeService);


/***/ }),
/* 131 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceTypeController = void 0;
const common_1 = __webpack_require__(3);
const create_dto_1 = __webpack_require__(132);
const update_dto_1 = __webpack_require__(133);
const dto_pipe_1 = __webpack_require__(65);
const device_type_service_1 = __webpack_require__(130);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
let DeviceTypeController = class DeviceTypeController {
    constructor(service) {
        this.service = service;
    }
    async list() {
        const rows = await this.service.list();
        return response_util_1.ResponseUtilService.successRes(rows);
    }
    async options() {
        const rows = await this.service.options();
        return response_util_1.ResponseUtilService.successRes(rows);
    }
    async add(dto, req) {
        try {
            const r = await this.service.add(dto, req[constant_1.ReqAttrs.MEMBER_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async paramsField(id) {
        if (id < 1)
            return null;
        const rows = await this.service.paramsField(id);
        return response_util_1.ResponseUtilService.successRes(rows);
    }
};
exports.DeviceTypeController = DeviceTypeController;
__decorate([
    (0, common_1.Get)('list'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], DeviceTypeController.prototype, "list", null);
__decorate([
    (0, common_1.Get)('options'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], DeviceTypeController.prototype, "options", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceTypeController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _c : Object]),
    __metadata("design:returntype", Promise)
], DeviceTypeController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], DeviceTypeController.prototype, "del", null);
__decorate([
    (0, common_1.Get)('paramsField/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], DeviceTypeController.prototype, "paramsField", null);
exports.DeviceTypeController = DeviceTypeController = __decorate([
    (0, common_1.Controller)('deviceType'),
    __metadata("design:paramtypes", [typeof (_a = typeof device_type_service_1.DeviceTypeService !== "undefined" && device_type_service_1.DeviceTypeService) === "function" ? _a : Object])
], DeviceTypeController);


/***/ }),
/* 132 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(30),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "code", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "parentId", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "sort", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(15),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "aliProduct", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);
__decorate([
    (0, class_validator_1.ArrayMaxSize)(50),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Array)
], CreateDto.prototype, "paramFields", void 0);


/***/ }),
/* 133 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(132);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 134 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceModule = void 0;
const common_1 = __webpack_require__(3);
const device_service_1 = __webpack_require__(135);
const device_controller_1 = __webpack_require__(143);
const device_type_module_1 = __webpack_require__(129);
let DeviceModule = class DeviceModule {
};
exports.DeviceModule = DeviceModule;
exports.DeviceModule = DeviceModule = __decorate([
    (0, common_1.Module)({
        imports: [device_type_module_1.DeviceTypeModule],
        providers: [device_service_1.DeviceService,],
        controllers: [device_controller_1.DeviceController]
    })
], DeviceModule);


/***/ }),
/* 135 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const dayjs = __webpack_require__(59);
const typeorm_1 = __webpack_require__(23);
const work_exception_1 = __webpack_require__(60);
const device_type_service_1 = __webpack_require__(130);
const alicloud_1 = __webpack_require__(136);
const configure_1 = __webpack_require__(6);
let DeviceService = class DeviceService {
    constructor(db, deviceTypeService, alicloud, config) {
        this.db = db;
        this.deviceTypeService = deviceTypeService;
        this.alicloud = alicloud;
        this.config = config;
    }
    async page(dto) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {};
        if (dto.id) {
            const ids = dto.id.split(',').map(item => Number(item)).filter(item => !isNaN(item) && item > 0);
            if (ids.length == 1) {
                where.id = ids[0];
            }
            else if (ids.length > 1) {
                where.id = (0, typeorm_1.In)(ids);
            }
        }
        if (dto.name) {
            where.name = (0, typeorm_1.Like)('%' + dto.name + '%');
        }
        if (dto.merchantId) {
            where.merchantId = dto.merchantId;
        }
        if (dto.connectStatus !== undefined) {
            where.connectStatus = dto.connectStatus;
        }
        if (dto.deviceTypeId) {
            const deviceType = await this.db.deviceType.findOne({ id: dto.deviceTypeId });
            if (!deviceType)
                return result;
            const deviceTypeIds = [dto.deviceTypeId];
            const subRows = await this.db.deviceType.find({ topId: deviceType.parentId == 0 ? dto.deviceTypeId : deviceType.topId });
            if (subRows.length > 0) {
                const subIds = [];
                this.deviceTypeService.querySubCategory(subRows, subIds, dto.deviceTypeId);
                deviceTypeIds.push(...subIds);
            }
            where.deviceTypeId = (0, typeorm_1.In)(deviceTypeIds);
        }
        result.total = await this.db.device.count(where);
        if (result.total > 0) {
            result.rows = await this.db.device.pagination(dto.pageNo, dto.pageSize, where, null, { id: 'DESC' });
            if (result.rows.length > 0) {
                const merchantIds = [];
                const deviceTypeIds = [];
                result.rows.forEach(row => {
                    if (row.merchantId > 0 && !merchantIds.includes(row.merchantId)) {
                        merchantIds.push(row.merchantId);
                    }
                    if (row.deviceTypeId > 0 && !deviceTypeIds.includes(row.deviceTypeId)) {
                        deviceTypeIds.push(row.deviceTypeId);
                    }
                });
                if (merchantIds.length > 0 || deviceTypeIds.length > 0) {
                    const merchants = await this.db.merchant.find({ id: (0, typeorm_1.In)(merchantIds) }, { id: true, name: true });
                    const deviceTypes = await this.db.deviceType.find({ id: (0, typeorm_1.In)(deviceTypeIds) }, { id: true, name: true });
                    if (merchants.length > 0 || deviceTypes.length > 0) {
                        result.rows.forEach(row => {
                            if (row.merchantId > 0) {
                                const merchant = merchants.find(item => item.id == row.merchantId);
                                if (merchant) {
                                    row.merchant = merchant;
                                }
                            }
                            if (row.deviceTypeId > 0) {
                                const deviceType = deviceTypes.find(item => item.id == row.deviceTypeId);
                                if (deviceType) {
                                    row.deviceType = deviceType;
                                }
                            }
                        });
                    }
                }
            }
        }
        return result;
    }
    async add(dto, memberId) {
        const deviceType = await this.db.deviceType.findOne({ id: dto.deviceTypeId }, ['id', 'aliProduct']);
        if (!deviceType || !deviceType.aliProduct)
            return false;
        const time = dayjs().unix();
        const toAli = dto.toAli;
        delete dto.toAli;
        const count = dto.count;
        delete dto.count;
        const devices = [];
        for (let i = 0; i < count; i++) {
            devices.push({ creatorId: memberId, createTime: time, ...dto });
        }
        const r = await this.db.device.insert(devices);
        if (r.affectedRows < 1)
            return false;
        if (toAli) {
            const deviceNames = r.rows.map(row => String(row.id));
            if (deviceNames.length == 1) {
                await this.singleRegisterDevice(deviceType.aliProduct, deviceNames[0]);
            }
            else {
                await this.batchRegisterDevice(deviceType.aliProduct, deviceNames);
            }
        }
        return true;
    }
    async singleRegisterDevice(productKey, deviceName) {
        const r = await this.alicloud.registerDevice(productKey, deviceName);
        if (!r)
            return;
        if (r.success) {
            await this.db.device.update({ id: Number(deviceName) }, { aliSecret: r.data.deviceSecret });
        }
        else {
            if (r.code == 'iot.device.AlreadyExistedDeviceName') {
                const res = await this.alicloud.queryDeviceInfo(productKey, deviceName);
                if (res.success) {
                    await this.db.device.update({ id: Number(deviceName) }, { aliSecret: res.data.deviceSecret, atAli: true });
                }
            }
        }
    }
    async batchRegisterDevice(productKey, deviceNames) {
        const r = await this.alicloud.batchQueryDeviceDetail(productKey, deviceNames);
        if (!r)
            return;
        if (r.success && r.data) {
            r.data.data.forEach(row => {
                deviceNames.splice(deviceNames.indexOf(row.deviceName), 1);
                this.db.device.update({ id: Number(row.deviceName) }, { aliSecret: row.deviceSecret, atAli: true });
            });
        }
        if (deviceNames.length > 0) {
            const r = await this.alicloud.batchCheckDeviceNames(productKey, deviceNames);
            if (!r)
                return;
            if (r.success && r.data) {
                const r0 = await this.alicloud.batchRegisterDeviceWithApplyId(productKey, r.data.applyId);
                setTimeout(async () => {
                    const r1 = await this.alicloud.batchQueryDeviceDetail(productKey, deviceNames);
                    if (!r1)
                        return;
                    if (r1.success && r1.data) {
                        r1.data.data.forEach(row => {
                            this.db.device.update({ id: Number(row.deviceName) }, { aliSecret: row.deviceSecret, atAli: true });
                        });
                    }
                }, 2000);
            }
        }
    }
    async update(dto) {
        const id = dto.id;
        const row = await this.db.device.findOne({ id: id });
        if (!row)
            return false;
        const updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (dto[k] != row[k]) {
                    updateData[k] = dto[k];
                }
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.merchantId != undefined) {
            updateData.stationId = 0;
        }
        if (updateData.aliSecret !== undefined && updateData.aliSecret === '') {
            updateData.atAli = false;
        }
        const r = await this.db.device.update({ id: id }, updateData);
        return r == 1;
    }
    async del(id, syncDelAli = false) {
        let row = await this.db.device.findOne({ id }, ['id', 'deviceTypeId']);
        if (!row)
            return false;
        const r = await this.db.device.delete({ id: id });
        if (r > 0 && syncDelAli) {
            const deviceType = await this.db.deviceType.findOne({ id: row.deviceTypeId }, ['id', 'aliProduct']);
            this.alicloud.deleteDevice(deviceType.aliProduct, String(id));
        }
        return r;
    }
    async manyDeviceRegisterToAli(deviceIds) {
        const devices = await this.db.device.find({ id: (0, typeorm_1.In)(deviceIds) }, ['id', 'deviceTypeId']);
        if (devices.length == 0)
            return true;
        const deviceTypes = await this.db.deviceType.find({ id: (0, typeorm_1.In)(devices.map(item => item.deviceTypeId)) }, ['id', 'aliProduct']);
        const dataMap = {};
        deviceTypes.forEach(item => {
            dataMap[item.id] = {
                aliProduct: item.aliProduct,
                deviceNames: []
            };
        });
        devices.forEach(item => {
            if (dataMap[item.deviceTypeId] != undefined) {
                dataMap[item.deviceTypeId].deviceNames.push(String(item.id));
            }
        });
        for (let k in dataMap) {
            const row = dataMap[k];
            if (row.deviceNames.length == 1) {
                await this.singleRegisterDevice(row.aliProduct, row.deviceNames[0]);
            }
            else if (row.deviceNames.length > 1) {
                await this.batchRegisterDevice(row.aliProduct, row.deviceNames);
            }
        }
        return true;
    }
    async bindMerchant(merchantId, deviceIds) {
        const devices = await this.db.device.find({ id: (0, typeorm_1.In)(deviceIds) }, ['id', 'merchantId']);
        if (devices.findIndex(item => item.merchantId != 0) >= 0)
            throw new work_exception_1.default('已绑定商户的设备请先解绑商户');
        await this.db.device.update({ id: (0, typeorm_1.In)(deviceIds) }, { merchantId });
        return true;
    }
    async unbindMerchant(deviceIds) {
        await this.db.device.update({ id: (0, typeorm_1.In)(deviceIds) }, { merchantId: 0, stationId: 0 });
        return true;
    }
    async setParams(dto, merchantId) {
        const topicReg = this.config.get('ALI_TO_DEVICE_TOPIC_REG');
        const params = await this.db.deviceParams.findOne({ id: dto.id });
        const content = params.params;
        const size = 100;
        if (dto.range == 2) {
            const deviceType = await this.db.deviceType.findOne({ id: params.deviceTypeId }, { id: true, aliProduct: true });
            const where = {
                deviceTypeId: params.deviceTypeId
            };
            if (merchantId > 0) {
                where.merchantId = merchantId;
            }
            let devices = await this.db.device.find(where, { id: true, connectStatus: true });
            devices = devices.filter(device => device.connectStatus);
            const len = devices.length;
            if (len == 0)
                return;
            const topic = topicReg.replace(/\?/, deviceType.aliProduct);
            for (let i = 0; i < len; i += size) {
                const deviceType = await this.db.deviceType.findOne({ id: params.deviceTypeId }, { id: true, aliProduct: true });
                await this.alicloud.batchPub(deviceType.aliProduct, topic, devices.slice(i, i + size).map(item => String(item.id)), content);
            }
        }
        else if (dto.range == 3) {
            const deviceTypeIds = [];
            const deviceType = await this.db.deviceType.findOne({ id: params.deviceTypeId }, { id: true, aliProduct: true, parentId: true, topId: true });
            deviceTypeIds.push(deviceType.id);
            const deviceTypeRows = await this.db.deviceType.find({ topId: deviceType.parentId == 0 ? deviceType.id : deviceType.topId }, { id: true, aliProduct: true, parentId: true, topId: true });
            if (deviceTypeRows.length > 0) {
                const subIds = [];
                this.deviceTypeService.querySubCategory(deviceTypeRows, subIds, deviceType.id);
                deviceTypeIds.push(...subIds);
            }
            const where = { deviceTypeId: (0, typeorm_1.In)(deviceTypeIds) };
            if (merchantId > 0) {
                where.merchantId = merchantId;
            }
            let devices = await this.db.device.find(where, { id: true, deviceTypeId: true, connectStatus: true });
            devices = devices.filter(device => device.connectStatus);
            if (devices.length == 0)
                return;
            deviceTypeRows.push(deviceType);
            const deviceMap = {};
            devices.forEach(device => {
                const id = String(device.id);
                if (!deviceMap[device.deviceTypeId]) {
                    deviceMap[device.deviceTypeId] = [];
                }
                deviceMap[device.deviceTypeId].push(id);
            });
            for (let k in deviceMap) {
                const type = deviceTypeRows.find(item => item.id == Number(k));
                const deviceIds = deviceMap[k];
                const len = deviceIds.length;
                const topic = topicReg.replace(/\?/, type.aliProduct);
                for (let i = 0; i < len; i += size) {
                    await this.alicloud.batchPub(type.aliProduct, topic, deviceIds.slice(i, i + size), content);
                }
            }
        }
        else if (dto.range == 1) {
            if (!dto.deviceIds)
                return;
            const where = { id: (0, typeorm_1.In)(dto.deviceIds) };
            if (merchantId > 0) {
                where.merchantId = merchantId;
            }
            let devices = await this.db.device.find(where, { id: true, deviceTypeId: true, connectStatus: true });
            devices = devices.filter(device => device.connectStatus);
            if (devices.length == 0)
                return;
            const deviceTypeIds = [];
            devices.forEach(device => {
                if (!deviceTypeIds.includes(device.deviceTypeId)) {
                    deviceTypeIds.push(device.deviceTypeId);
                }
            });
            const deviceTypes = await this.db.deviceType.find({ id: (0, typeorm_1.In)(deviceTypeIds) }, { id: true, aliProduct: true });
            const deviceMap = {};
            devices.forEach(device => {
                const id = String(device.id);
                if (!deviceMap[device.deviceTypeId]) {
                    deviceMap[device.deviceTypeId] = [];
                }
                deviceMap[device.deviceTypeId].push(id);
            });
            for (let k in deviceMap) {
                const type = deviceTypes.find(item => item.id == Number(k));
                const deviceIds = deviceMap[k];
                const len = deviceIds.length;
                console.log(topicReg);
                const topic = topicReg.replace(/\?/, type.aliProduct);
                console.log(topic);
                for (let i = 0; i < len; i += size) {
                    await this.alicloud.batchPub(type.aliProduct, topic, deviceIds.slice(i, i + size), content);
                }
            }
        }
    }
};
exports.DeviceService = DeviceService;
exports.DeviceService = DeviceService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object, typeof (_b = typeof device_type_service_1.DeviceTypeService !== "undefined" && device_type_service_1.DeviceTypeService) === "function" ? _b : Object, typeof (_c = typeof alicloud_1.AlicloudService !== "undefined" && alicloud_1.AlicloudService) === "function" ? _c : Object, typeof (_d = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _d : Object])
], DeviceService);


/***/ }),
/* 136 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(137), exports);
__exportStar(__webpack_require__(138), exports);


/***/ }),
/* 137 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AlicloudModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AlicloudModule = void 0;
const common_1 = __webpack_require__(3);
const alicloud_service_1 = __webpack_require__(138);
let AlicloudModule = AlicloudModule_1 = class AlicloudModule {
    static forRootAsync(options) {
        const providers = [
            {
                provide: 'ALI_MODULE_OPTIONS',
                useFactory: options.useFactory,
                inject: options.inject || [],
            },
            alicloud_service_1.AlicloudService,
        ];
        return {
            module: AlicloudModule_1,
            providers: providers,
            exports: [alicloud_service_1.AlicloudService],
        };
    }
};
exports.AlicloudModule = AlicloudModule;
exports.AlicloudModule = AlicloudModule = AlicloudModule_1 = __decorate([
    (0, common_1.Global)()
], AlicloudModule);


/***/ }),
/* 138 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AlicloudService = void 0;
const common_1 = __webpack_require__(3);
const iot20180120_1 = __webpack_require__(139), $Iot = iot20180120_1;
const $OpenApi = __webpack_require__(140);
const IotCofig_1 = __webpack_require__(141);
const node_crypto_1 = __webpack_require__(142);
let AlicloudService = class AlicloudService {
    constructor(options) {
        this.options = options;
        this.iotClient();
    }
    iotClient() {
        let config = new $OpenApi.Config({
            accessKeyId: this.options.accessKeyId,
            accessKeySecret: this.options.accessKeySecret,
            regionId: this.options.regionId
        });
        this.client = new iot20180120_1.default(config);
    }
    async registerDevice(productKey, deviceName) {
        try {
            const req = new $Iot.RegisterDeviceRequest({
                productKey,
                deviceName: deviceName,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.registerDevice(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async queryDeviceInfo(productKey, deviceName) {
        try {
            const req = new $Iot.QueryDeviceInfoRequest({
                productKey,
                deviceName: deviceName,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.queryDeviceInfo(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchQueryDeviceDetail(productKey, deviceNames) {
        try {
            const req = new $Iot.BatchQueryDeviceDetailRequest({
                deviceName: deviceNames,
                productKey: productKey,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchQueryDeviceDetail(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchCheckDeviceNames(productKey, deviceNames) {
        try {
            const req = new $Iot.BatchCheckDeviceNamesRequest({
                productKey,
                deviceName: deviceNames,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchCheckDeviceNames(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchRegisterDeviceWithApplyId(productKey, applyId) {
        try {
            const req = new $Iot.BatchRegisterDeviceWithApplyIdRequest({
                productKey,
                applyId: applyId,
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchRegisterDeviceWithApplyId(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async deleteDevice(productKey, deviceName) {
        try {
            const req = new $Iot.DeleteDeviceRequest({
                productKey: productKey,
                deviceName: deviceName
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.deleteDevice(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async batchPub(productKey, topicTemplateName, deviceNames, messageContent, options = {}) {
        try {
            const req = new $Iot.BatchPubRequest({
                productKey: productKey,
                deviceName: deviceNames,
                topicTemplateName: topicTemplateName,
                messageContent: Buffer.from(JSON.stringify(messageContent)).toString('base64'),
                ...options
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.batchPub(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
    async pub(productKey, topicFullName, deviceName, messageContent, options = {}) {
        try {
            console.log(messageContent);
            if (!messageContent.msgId) {
                messageContent.msgId = (0, node_crypto_1.createHash)('md5').update(Date.now() + deviceName).digest('hex').toLowerCase().substring(0, 16);
            }
            else {
                if (messageContent.msgId.length < 16) {
                    messageContent.msgId = messageContent.msgId.padStart(16, '0');
                }
            }
            const req = new $Iot.PubRequest({
                productKey: productKey,
                deviceName: deviceName,
                topicFullName: topicFullName,
                messageContent: Buffer.from(JSON.stringify(messageContent)).toString('base64'),
                ...options
            });
            if (this.options.iotInstanceId) {
                req.iotInstanceId = this.options.iotInstanceId;
            }
            const r = await this.client.pub(req);
            if (r.statusCode == 200)
                return r.body;
        }
        catch (error) {
        }
        return null;
    }
};
exports.AlicloudService = AlicloudService;
exports.AlicloudService = AlicloudService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)('ALI_MODULE_OPTIONS')),
    __metadata("design:paramtypes", [typeof (_a = typeof IotCofig_1.IotConfig !== "undefined" && IotCofig_1.IotConfig) === "function" ? _a : Object])
], AlicloudService);


/***/ }),
/* 139 */
/***/ ((module) => {

module.exports = require("@alicloud/iot20180120");

/***/ }),
/* 140 */
/***/ ((module) => {

module.exports = require("@alicloud/openapi-client");

/***/ }),
/* 141 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));


/***/ }),
/* 142 */
/***/ ((module) => {

module.exports = require("node:crypto");

/***/ }),
/* 143 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d, _e, _f, _g, _h;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceController = void 0;
const common_1 = __webpack_require__(3);
const device_service_1 = __webpack_require__(135);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(144);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
const page_dto_1 = __webpack_require__(145);
const update_dto_1 = __webpack_require__(146);
const registerToAli_dto_1 = __webpack_require__(147);
const bindMerchant_dto_1 = __webpack_require__(148);
const unbindMerchant_dto_1 = __webpack_require__(149);
const setParams_dto_1 = __webpack_require__(150);
let DeviceController = class DeviceController {
    constructor(service) {
        this.service = service;
    }
    async page(dto, req) {
        const result = await this.service.page(dto);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async add(dto, req) {
        try {
            const r = await this.service.add(dto, req[constant_1.ReqAttrs.MEMBER_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id, syncDelAli) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id, syncDelAli);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async registerToAli(dto, req) {
        try {
            await this.service.manyDeviceRegisterToAli(dto.ids);
            return response_util_1.ResponseUtilService.successRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async bindMerchant(dto, req) {
        try {
            await this.service.bindMerchant(dto.merchantId, dto.ids);
            return response_util_1.ResponseUtilService.successRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async unbindMerchant(dto, req) {
        try {
            await this.service.unbindMerchant(dto.ids);
            return response_util_1.ResponseUtilService.successRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async setParams(dto, req) {
        try {
            await this.service.setParams(dto, req[constant_1.ReqAttrs.MERCHANT_ID]);
            return response_util_1.ResponseUtilService.successRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.DeviceController = DeviceController;
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _c : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_d = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _d : Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Body)('syncDelAli')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Boolean]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "del", null);
__decorate([
    (0, common_1.Post)('registerToAli'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_e = typeof registerToAli_dto_1.default !== "undefined" && registerToAli_dto_1.default) === "function" ? _e : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "registerToAli", null);
__decorate([
    (0, common_1.Post)('bindMerchant'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_f = typeof bindMerchant_dto_1.default !== "undefined" && bindMerchant_dto_1.default) === "function" ? _f : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "bindMerchant", null);
__decorate([
    (0, common_1.Post)('unbindMerchant'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_g = typeof unbindMerchant_dto_1.default !== "undefined" && unbindMerchant_dto_1.default) === "function" ? _g : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "unbindMerchant", null);
__decorate([
    (0, common_1.Post)("setParams"),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_h = typeof setParams_dto_1.default !== "undefined" && setParams_dto_1.default) === "function" ? _h : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceController.prototype, "setParams", null);
exports.DeviceController = DeviceController = __decorate([
    (0, common_1.Controller)('device'),
    __metadata("design:paramtypes", [typeof (_a = typeof device_service_1.DeviceService !== "undefined" && device_service_1.DeviceService) === "function" ? _a : Object])
], DeviceController);


/***/ }),
/* 144 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.Max)(100),
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "count", void 0);
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "deviceTypeId", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "merchantId", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "toAli", void 0);


/***/ }),
/* 145 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "id", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "merchantId", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "deviceTypeId", void 0);
__decorate([
    (0, class_validator_1.Max)(1),
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "connectStatus", void 0);


/***/ }),
/* 146 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(144);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.OmitType)(create_dto_1.default, ['toAli', 'count']) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(35),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], UpdateDto.prototype, "aliSecret", void 0);


/***/ }),
/* 147 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class RegisterToAliDto {
}
exports["default"] = RegisterToAliDto;
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.ArrayMinSize)(1),
    (0, class_validator_1.IsArray)(),
    __metadata("design:type", Array)
], RegisterToAliDto.prototype, "ids", void 0);


/***/ }),
/* 148 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class BindMerchantDto {
}
exports["default"] = BindMerchantDto;
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.ArrayMinSize)(1),
    (0, class_validator_1.IsArray)(),
    __metadata("design:type", Array)
], BindMerchantDto.prototype, "ids", void 0);
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], BindMerchantDto.prototype, "merchantId", void 0);


/***/ }),
/* 149 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const class_validator_1 = __webpack_require__(68);
const bindMerchant_dto_1 = __webpack_require__(148);
class UnbnindMerchantDto extends (0, mapped_types_1.OmitType)(bindMerchant_dto_1.default, ['merchantId']) {
}
exports["default"] = UnbnindMerchantDto;
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.ArrayMinSize)(1),
    (0, class_validator_1.IsArray)(),
    __metadata("design:type", Array)
], UnbnindMerchantDto.prototype, "ids", void 0);


/***/ }),
/* 150 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class SetParamsDto {
}
exports["default"] = SetParamsDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], SetParamsDto.prototype, "id", void 0);
__decorate([
    (0, class_validator_1.Max)(1),
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], SetParamsDto.prototype, "range", void 0);
__decorate([
    (0, class_validator_1.ArrayMaxSize)(100),
    (0, class_validator_1.ArrayMinSize)(1),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Array)
], SetParamsDto.prototype, "deviceIds", void 0);


/***/ }),
/* 151 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsFieldModule = void 0;
const common_1 = __webpack_require__(3);
const device_params_field_service_1 = __webpack_require__(152);
const device_params_field_controller_1 = __webpack_require__(153);
let DeviceParamsFieldModule = class DeviceParamsFieldModule {
};
exports.DeviceParamsFieldModule = DeviceParamsFieldModule;
exports.DeviceParamsFieldModule = DeviceParamsFieldModule = __decorate([
    (0, common_1.Module)({
        providers: [device_params_field_service_1.DeviceParamsFieldService],
        controllers: [device_params_field_controller_1.DeviceParamsFieldController]
    })
], DeviceParamsFieldModule);


/***/ }),
/* 152 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsFieldService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const dayjs = __webpack_require__(59);
const typeorm_1 = __webpack_require__(23);
let DeviceParamsFieldService = class DeviceParamsFieldService {
    constructor(db) {
        this.db = db;
    }
    async options() {
        return this.db.deviceParamsField.find({ enable: true }, { id: true, name: true });
    }
    async page(dto) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {};
        if (dto.name) {
            where.name = (0, typeorm_1.Like)('%' + dto.name + '%');
        }
        result.total = await this.db.deviceParamsField.count(where);
        if (result.total > 0) {
            result.rows = await this.db.deviceParamsField.pagination(dto.pageNo, dto.pageSize, where, null, { id: 'DESC' });
        }
        return result;
    }
    async add(dto, memberId) {
        if (true == await this.db.deviceParamsField.isExistsByWhere({ name: dto.name }))
            throw new Error('已存在相同的名称');
        if (true == await this.db.deviceParamsField.isExistsByWhere({ key: dto.key }))
            throw new Error('已存在相同的参数名');
        return this.db.deviceParamsField.insert({ ...dto, creatorId: memberId, createTime: dayjs().unix() });
    }
    async update(dto) {
        let fields = Object.keys(dto);
        if (fields.length == 0)
            return true;
        const row = await this.db.deviceParamsField.findOne({ id: dto.id });
        if (!row)
            return false;
        let updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (k == 'options') {
                    if (JSON.stringify(dto.options) == JSON.stringify(row.options))
                        continue;
                }
                else {
                    if (row[k] == dto[k])
                        continue;
                }
                updateData[k] = dto[k];
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.name && (true == await this.db.deviceParamsField.isExistsByWhere({ name: dto.name })))
            throw new Error('已存在相同的名称');
        if (updateData.key && (true == await this.db.deviceParamsField.isExistsByWhere({ key: dto.key })))
            throw new Error('已存在相同的参数名');
        updateData.updateTime = dayjs().unix();
        return this.db.deviceParamsField.update({ id: dto.id }, updateData);
    }
    async del(id) {
        let row = await this.db.deviceParamsField.findOne({ id }, ['id']);
        if (!row)
            return;
        return this.db.deviceParamsField.delete({ id: id });
    }
};
exports.DeviceParamsFieldService = DeviceParamsFieldService;
exports.DeviceParamsFieldService = DeviceParamsFieldService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], DeviceParamsFieldService);


/***/ }),
/* 153 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsFieldController = void 0;
const common_1 = __webpack_require__(3);
const device_params_field_service_1 = __webpack_require__(152);
const response_util_1 = __webpack_require__(62);
const dto_pipe_1 = __webpack_require__(65);
const page_dto_1 = __webpack_require__(154);
const create_dto_1 = __webpack_require__(155);
const constant_1 = __webpack_require__(61);
const update_dto_1 = __webpack_require__(156);
let DeviceParamsFieldController = class DeviceParamsFieldController {
    constructor(service) {
        this.service = service;
    }
    async list() {
        const result = await this.service.options();
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async page(dto) {
        const result = await this.service.page(dto);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async add(dto, req) {
        const memberId = req[constant_1.ReqAttrs.MEMBER_ID];
        try {
            const r = await this.service.add(dto, memberId);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id, req) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.DeviceParamsFieldController = DeviceParamsFieldController;
__decorate([
    (0, common_1.Get)('options'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], DeviceParamsFieldController.prototype, "list", null);
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsFieldController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _c : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsFieldController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_d = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _d : Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsFieldController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsFieldController.prototype, "del", null);
exports.DeviceParamsFieldController = DeviceParamsFieldController = __decorate([
    (0, common_1.Controller)('/deviceParamsField'),
    __metadata("design:paramtypes", [typeof (_a = typeof device_params_field_service_1.DeviceParamsFieldService !== "undefined" && device_params_field_service_1.DeviceParamsFieldService) === "function" ? _a : Object])
], DeviceParamsFieldController);


/***/ }),
/* 154 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "name", void 0);


/***/ }),
/* 155 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "key", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "inputType", void 0);
__decorate([
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Array)
], CreateDto.prototype, "options", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "unit", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);


/***/ }),
/* 156 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(155);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 157 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsModule = void 0;
const common_1 = __webpack_require__(3);
const device_params_service_1 = __webpack_require__(158);
const device_params_controller_1 = __webpack_require__(159);
let DeviceParamsModule = class DeviceParamsModule {
};
exports.DeviceParamsModule = DeviceParamsModule;
exports.DeviceParamsModule = DeviceParamsModule = __decorate([
    (0, common_1.Module)({
        providers: [device_params_service_1.DeviceParamsService],
        controllers: [device_params_controller_1.DeviceParamsController]
    })
], DeviceParamsModule);


/***/ }),
/* 158 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const typeorm_1 = __webpack_require__(23);
const dayjs = __webpack_require__(59);
let DeviceParamsService = class DeviceParamsService {
    constructor(db) {
        this.db = db;
    }
    async options(merchantId) {
        return this.db.deviceParams.find({ merchantId }, { id: true, name: true, params: () => true });
    }
    async page(dto, merchantId) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {
            merchantId
        };
        if (dto.name) {
            where.name = (0, typeorm_1.Like)('%' + dto.name + '%');
        }
        result.total = await this.db.deviceParams.count(where);
        if (result.total > 0) {
            result.rows = await this.db.deviceParams.pagination(dto.pageNo, dto.pageSize, where, null, { id: 'DESC' });
            const typeIds = [];
            const paramKeys = [];
            result.rows.forEach(row => {
                if (!typeIds.includes(row.deviceTypeId)) {
                    typeIds.push(row.deviceTypeId);
                }
                if (row.params) {
                    for (let k in row.params) {
                        if (!paramKeys.includes(k)) {
                            paramKeys.push(k);
                        }
                    }
                }
            });
            const deviceTypes = await this.db.deviceType.find({ id: (0, typeorm_1.In)(typeIds) }, { id: true, name: true });
            const paramsFields = await this.db.deviceParamsField.find({ key: (0, typeorm_1.In)(paramKeys) }, { id: true, key: true, name: true });
            result.rows.forEach(row => {
                const deviceType = deviceTypes.find(item => item.id == row.deviceTypeId);
                row.deviceType = deviceType;
                if (row.params) {
                    const paramsExplain = {};
                    for (let k in row.params) {
                        const field = paramsFields.find(item => item.key == k);
                        paramsExplain[field.name] = row.params[k];
                    }
                    row.paramsExplain = paramsExplain;
                }
            });
        }
        return result;
    }
    async add(dto, memberId, merchantId) {
        if (true == await this.db.deviceParams.isExistsByWhere({ name: dto.name, merchantId }))
            throw new Error('已存在相同的名称');
        return this.db.deviceParams.insert({ ...dto, creatorId: memberId, merchantId: merchantId, createTime: dayjs().unix() });
    }
    async update(dto, merchantId) {
        let fields = Object.keys(dto);
        if (fields.length == 0)
            return true;
        const row = await this.db.deviceParams.findOne({ id: dto.id });
        if (!row || row.merchantId != merchantId)
            return false;
        let updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (k == 'params') {
                    if (JSON.stringify(dto.params) == JSON.stringify(row.params))
                        continue;
                }
                else {
                    if (row[k] == dto[k])
                        continue;
                }
                updateData[k] = dto[k];
            }
        }
        if (Object.keys(updateData).length == 0)
            return true;
        if (updateData.name && (true == await this.db.deviceParams.isExistsByWhere({ name: dto.name, merchantId })))
            throw new Error('已存在相同的名称');
        updateData.updateTime = dayjs().unix();
        return this.db.deviceParams.update({ id: dto.id }, updateData);
    }
    async del(id, merchantId) {
        let row = await this.db.deviceParams.findOne({ id }, ['id', 'merchantId']);
        if (!row || row.merchantId != merchantId)
            return;
        return this.db.deviceParams.delete({ id: id });
    }
};
exports.DeviceParamsService = DeviceParamsService;
exports.DeviceParamsService = DeviceParamsService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], DeviceParamsService);


/***/ }),
/* 159 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceParamsController = void 0;
const common_1 = __webpack_require__(3);
const device_params_service_1 = __webpack_require__(158);
const constant_1 = __webpack_require__(61);
const response_util_1 = __webpack_require__(62);
const dto_pipe_1 = __webpack_require__(65);
const page_dto_1 = __webpack_require__(160);
const create_dto_1 = __webpack_require__(161);
const update_dto_1 = __webpack_require__(162);
let DeviceParamsController = class DeviceParamsController {
    constructor(service) {
        this.service = service;
    }
    async list(req) {
        const result = await this.service.options(req[constant_1.ReqAttrs.MERCHANT_ID]);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async page(dto, req) {
        const result = await this.service.page(dto, req[constant_1.ReqAttrs.MERCHANT_ID]);
        return response_util_1.ResponseUtilService.successRes(result);
    }
    async add(dto, req) {
        try {
            const r = await this.service.add(dto, req[constant_1.ReqAttrs.MEMBER_ID], req[constant_1.ReqAttrs.MERCHANT_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto, req) {
        try {
            const r = await this.service.update(dto, req[constant_1.ReqAttrs.MERCHANT_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id, req) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id, req[constant_1.ReqAttrs.MERCHANT_ID]);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.DeviceParamsController = DeviceParamsController;
__decorate([
    (0, common_1.Get)('options'),
    __param(0, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsController.prototype, "list", null);
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsController.prototype, "page", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _c : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_d = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _d : Object, Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], DeviceParamsController.prototype, "del", null);
exports.DeviceParamsController = DeviceParamsController = __decorate([
    (0, common_1.Controller)('deviceParams'),
    __metadata("design:paramtypes", [typeof (_a = typeof device_params_service_1.DeviceParamsService !== "undefined" && device_params_service_1.DeviceParamsService) === "function" ? _a : Object])
], DeviceParamsController);


/***/ }),
/* 160 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], PageDto.prototype, "name", void 0);


/***/ }),
/* 161 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(20),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsInt)(),
    __metadata("design:type", Number)
], CreateDto.prototype, "deviceTypeId", void 0);
__decorate([
    (0, class_validator_1.IsObject)(),
    __metadata("design:type", Object)
], CreateDto.prototype, "params", void 0);


/***/ }),
/* 162 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(161);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 163 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigModule = void 0;
const common_1 = __webpack_require__(3);
const sys_config_service_1 = __webpack_require__(164);
const sys_config_controller_1 = __webpack_require__(165);
let SysConfigModule = class SysConfigModule {
};
exports.SysConfigModule = SysConfigModule;
exports.SysConfigModule = SysConfigModule = __decorate([
    (0, common_1.Module)({
        providers: [sys_config_service_1.SysConfigService],
        controllers: [sys_config_controller_1.SysConfigController]
    })
], SysConfigModule);


/***/ }),
/* 164 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const work_exception_1 = __webpack_require__(60);
let SysConfigService = class SysConfigService {
    constructor(db) {
        this.db = db;
    }
    config() {
        return this.db.sysConfig.selectValues('STATIC_URL');
    }
    list() {
        return this.db.sysConfig.find(null, null, null, null, { id: 'DESC' });
    }
    async add(dto) {
        if ((await this.db.sysConfig.isExistsByWhere({ name: dto.name })))
            throw new work_exception_1.default('已存在相同的名称');
        if ((await this.db.sysConfig.isExistsByWhere({ code: dto.code })))
            throw new work_exception_1.default('已存在相同的编码');
        const r = await this.db.sysConfig.insert(dto);
        return r;
    }
    async update(dto) {
        const row = await this.db.sysConfig.findOne({ id: dto.id });
        if (!row)
            return false;
        let updateData = {};
        if (dto.name != undefined) {
            if (row.name != dto.name) {
                updateData.name = dto.name;
            }
        }
        if (dto.code != undefined) {
            if (row.code.toLocaleLowerCase() != dto.code.toLocaleLowerCase()) {
                updateData.code = dto.code;
            }
        }
        if (dto.config != undefined) {
            updateData.config = dto.config;
        }
        if ((Object.keys(updateData)).length == 0)
            return true;
        if (updateData.name && (await this.db.sysConfig.isExistsByWhere({ name: dto.name })))
            throw new Error('已存在相同的名称');
        if (updateData.code && (await this.db.sysConfig.isExistsByWhere({ code: dto.code })))
            throw new Error('已存在相同的编码');
        return this.db.sysConfig.update({ id: dto.id }, dto);
    }
    async updateItem(id, dto) {
        const row = await this.db.sysConfig.findOne({ id: id });
        if (!row)
            return false;
        for (let k in dto) {
            row.config[k].value = dto[k];
        }
        return this.db.sysConfig.update({ id: id }, { config: row.config });
    }
    async del(id) {
        let row = await this.db.sysConfig.findOne({ id });
        if (!row)
            return;
        return this.db.sysConfig.delete({ id: id });
    }
};
exports.SysConfigService = SysConfigService;
exports.SysConfigService = SysConfigService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], SysConfigService);


/***/ }),
/* 165 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SysConfigController = void 0;
const common_1 = __webpack_require__(3);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(166);
const sys_config_service_1 = __webpack_require__(164);
const response_util_1 = __webpack_require__(62);
const update_dto_1 = __webpack_require__(167);
let SysConfigController = class SysConfigController {
    constructor(service) {
        this.service = service;
    }
    async config() {
        const config = await this.service.config();
        return response_util_1.ResponseUtilService.successRes(config);
    }
    async list() {
        const rows = await this.service.list();
        return response_util_1.ResponseUtilService.successRes(rows);
    }
    async add(dto) {
        try {
            const r = await this.service.add(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async updateItem(id, dto) {
        try {
            const r = await this.service.updateItem(id, dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id, req) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.SysConfigController = SysConfigController;
__decorate([
    (0, common_1.Get)('configs'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], SysConfigController.prototype, "config", null);
__decorate([
    (0, common_1.Get)('list'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], SysConfigController.prototype, "list", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _b : Object]),
    __metadata("design:returntype", Promise)
], SysConfigController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _c : Object]),
    __metadata("design:returntype", Promise)
], SysConfigController.prototype, "update", null);
__decorate([
    (0, common_1.Put)('update/item/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], SysConfigController.prototype, "updateItem", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, Object]),
    __metadata("design:returntype", Promise)
], SysConfigController.prototype, "del", null);
exports.SysConfigController = SysConfigController = __decorate([
    (0, common_1.Controller)('sysconfig'),
    __metadata("design:paramtypes", [typeof (_a = typeof sys_config_service_1.SysConfigService !== "undefined" && sys_config_service_1.SysConfigService) === "function" ? _a : Object])
], SysConfigController);


/***/ }),
/* 166 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.MaxLength)(50),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "name", void 0);
__decorate([
    (0, class_validator_1.MaxLength)(50),
    (0, class_validator_1.IsNotEmpty)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateDto.prototype, "code", void 0);
__decorate([
    (0, class_validator_1.IsObject)(),
    __metadata("design:type", Object)
], CreateDto.prototype, "config", void 0);


/***/ }),
/* 167 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(166);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 168 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.OptionModule = void 0;
const common_1 = __webpack_require__(3);
const option_service_1 = __webpack_require__(169);
const option_controller_1 = __webpack_require__(170);
let OptionModule = class OptionModule {
};
exports.OptionModule = OptionModule;
exports.OptionModule = OptionModule = __decorate([
    (0, common_1.Module)({
        providers: [option_service_1.OptionService],
        controllers: [option_controller_1.OptionController]
    })
], OptionModule);


/***/ }),
/* 169 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.OptionService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
let OptionService = class OptionService {
    constructor(db) {
        this.db = db;
    }
    list() {
        return this.db.rechargeOption.find(null, null, null, null, { id: 'DESC' });
    }
    async add(dto) {
        return this.db.rechargeOption.insert(dto);
    }
    async update(dto) {
        const id = dto.id;
        const row = await this.db.rechargeOption.findOne({ id: id }, { enable: true, amount: true, reward: true });
        if (!row)
            return false;
        const updateData = {};
        for (let k in row) {
            if (k in dto) {
                if (dto[k] != row[k]) {
                    updateData[k] = dto[k];
                }
            }
        }
        return this.db.rechargeOption.update({ id }, updateData);
    }
    async del(id) {
        let row = await this.db.rechargeOption.findOne({ id }, ['id']);
        if (!row)
            return false;
        return this.db.rechargeOption.delete({ id: id });
    }
};
exports.OptionService = OptionService;
exports.OptionService = OptionService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], OptionService);


/***/ }),
/* 170 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.OptionController = void 0;
const common_1 = __webpack_require__(3);
const option_service_1 = __webpack_require__(169);
const response_util_1 = __webpack_require__(62);
const dto_pipe_1 = __webpack_require__(65);
const create_dto_1 = __webpack_require__(171);
const update_dto_1 = __webpack_require__(172);
let OptionController = class OptionController {
    constructor(service) {
        this.service = service;
    }
    async list() {
        const list = await this.service.list();
        return response_util_1.ResponseUtilService.successRes(list);
    }
    async add(dto) {
        try {
            const r = await this.service.add(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async update(dto) {
        try {
            const r = await this.service.update(dto);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
    async del(id) {
        if (id < 1)
            return null;
        try {
            const r = await this.service.del(id);
            return r ? response_util_1.ResponseUtilService.successRes() : response_util_1.ResponseUtilService.failRes();
        }
        catch (error) {
            return response_util_1.ResponseUtilService.failRes(error.message);
        }
    }
};
exports.OptionController = OptionController;
__decorate([
    (0, common_1.Get)('list'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], OptionController.prototype, "list", null);
__decorate([
    (0, common_1.Post)('add'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof create_dto_1.default !== "undefined" && create_dto_1.default) === "function" ? _b : Object]),
    __metadata("design:returntype", Promise)
], OptionController.prototype, "add", null);
__decorate([
    (0, common_1.Put)('update'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe())),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_c = typeof update_dto_1.default !== "undefined" && update_dto_1.default) === "function" ? _c : Object]),
    __metadata("design:returntype", Promise)
], OptionController.prototype, "update", null);
__decorate([
    (0, common_1.Delete)('delete/:id'),
    __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], OptionController.prototype, "del", null);
exports.OptionController = OptionController = __decorate([
    (0, common_1.Controller)('recharge/option'),
    __metadata("design:paramtypes", [typeof (_a = typeof option_service_1.OptionService !== "undefined" && option_service_1.OptionService) === "function" ? _a : Object])
], OptionController);


/***/ }),
/* 171 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const class_validator_1 = __webpack_require__(68);
class CreateDto {
}
exports["default"] = CreateDto;
__decorate([
    (0, class_validator_1.Min)(0.01),
    (0, class_validator_1.IsNumber)({}),
    __metadata("design:type", String)
], CreateDto.prototype, "amount", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsNumber)({}),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", String)
], CreateDto.prototype, "reward", void 0);
__decorate([
    (0, class_validator_1.IsBoolean)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Boolean)
], CreateDto.prototype, "enable", void 0);


/***/ }),
/* 172 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const mapped_types_1 = __webpack_require__(71);
const create_dto_1 = __webpack_require__(171);
const class_validator_1 = __webpack_require__(68);
class UpdateDto extends (0, mapped_types_1.PartialType)(create_dto_1.default) {
}
exports["default"] = UpdateDto;
__decorate([
    (0, class_validator_1.Min)(1),
    (0, class_validator_1.IsNumber)(),
    __metadata("design:type", Number)
], UpdateDto.prototype, "id", void 0);


/***/ }),
/* 173 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.OrderModule = void 0;
const common_1 = __webpack_require__(3);
const order_service_1 = __webpack_require__(174);
const order_controller_1 = __webpack_require__(175);
let OrderModule = class OrderModule {
};
exports.OrderModule = OrderModule;
exports.OrderModule = OrderModule = __decorate([
    (0, common_1.Module)({
        providers: [order_service_1.OrderService],
        controllers: [order_controller_1.OrderController]
    })
], OrderModule);


/***/ }),
/* 174 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.OrderService = void 0;
const common_1 = __webpack_require__(3);
let OrderService = class OrderService {
};
exports.OrderService = OrderService;
exports.OrderService = OrderService = __decorate([
    (0, common_1.Injectable)()
], OrderService);


/***/ }),
/* 175 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.OrderController = void 0;
const common_1 = __webpack_require__(3);
let OrderController = class OrderController {
};
exports.OrderController = OrderController;
exports.OrderController = OrderController = __decorate([
    (0, common_1.Controller)('order')
], OrderController);


/***/ }),
/* 176 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsModule = void 0;
const common_1 = __webpack_require__(3);
const water_bills_service_1 = __webpack_require__(177);
const water_bills_controller_1 = __webpack_require__(178);
let WaterBillsModule = class WaterBillsModule {
};
exports.WaterBillsModule = WaterBillsModule;
exports.WaterBillsModule = WaterBillsModule = __decorate([
    (0, common_1.Module)({
        providers: [water_bills_service_1.WaterBillsService],
        controllers: [water_bills_controller_1.WaterBillsController]
    })
], WaterBillsModule);


/***/ }),
/* 177 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsService = void 0;
const common_1 = __webpack_require__(3);
const db_service_1 = __webpack_require__(19);
const typeorm_1 = __webpack_require__(23);
let WaterBillsService = class WaterBillsService {
    constructor(db) {
        this.db = db;
    }
    async page(dto) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {};
        if (dto.deviceId && dto.deviceId > 0) {
            where.deviceId = dto.deviceId;
        }
        result.total = await this.db.waterBills.count(where);
        if (result.total > 0) {
            result.rows = await this.db.waterBills.pagination(dto.pageNo, dto.pageSize, where, null, { id: 'DESC' });
            if (result.rows.length > 0) {
                const userIds = [];
                result.rows.forEach(row => {
                    if (row.userId > 0 && !userIds.includes(row.userId)) {
                        userIds.push(row.userId);
                    }
                });
                if (userIds.length > 0) {
                    const users = await this.db.user.find({ id: (0, typeorm_1.In)(userIds) }, { id: true, nickname: true, avatar: true });
                    if (users.length > 0) {
                        result.rows.forEach(row => {
                            if (row.userId > 0) {
                                const user = users.find(item => item.id == row.userId);
                                if (user) {
                                    row.user = user;
                                }
                            }
                        });
                    }
                }
            }
        }
        return result;
    }
};
exports.WaterBillsService = WaterBillsService;
exports.WaterBillsService = WaterBillsService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], WaterBillsService);


/***/ }),
/* 178 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterBillsController = void 0;
const common_1 = __webpack_require__(3);
const water_bills_service_1 = __webpack_require__(177);
const page_dto_1 = __webpack_require__(179);
const dto_pipe_1 = __webpack_require__(65);
const response_util_1 = __webpack_require__(62);
let WaterBillsController = class WaterBillsController {
    constructor(service) {
        this.service = service;
    }
    async page(dto, req) {
        const result = await this.service.page(dto);
        return response_util_1.ResponseUtilService.successRes(result);
    }
};
exports.WaterBillsController = WaterBillsController;
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], WaterBillsController.prototype, "page", null);
exports.WaterBillsController = WaterBillsController = __decorate([
    (0, common_1.Controller)('waterBills'),
    __metadata("design:paramtypes", [typeof (_a = typeof water_bills_service_1.WaterBillsService !== "undefined" && water_bills_service_1.WaterBillsService) === "function" ? _a : Object])
], WaterBillsController);


/***/ }),
/* 179 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "deviceId", void 0);


/***/ }),
/* 180 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestModule = void 0;
const common_1 = __webpack_require__(3);
const water_test_service_1 = __webpack_require__(181);
const water_test_controller_1 = __webpack_require__(182);
let WaterTestModule = class WaterTestModule {
};
exports.WaterTestModule = WaterTestModule;
exports.WaterTestModule = WaterTestModule = __decorate([
    (0, common_1.Module)({
        providers: [water_test_service_1.WaterTestService],
        controllers: [water_test_controller_1.WaterTestController]
    })
], WaterTestModule);


/***/ }),
/* 181 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(23);
const db_service_1 = __webpack_require__(19);
let WaterTestService = class WaterTestService {
    constructor(db) {
        this.db = db;
    }
    async page(dto) {
        let result = {
            total: 0,
            rows: []
        };
        let where = {};
        if (dto.status != undefined) {
            where.status = dto.status;
        }
        if (dto.deviceId && dto.deviceId > 0) {
            where.deviceId = dto.deviceId;
        }
        if (dto.startTime || dto.endTime) {
            if (dto.startTime == dto.endTime) {
                where.createTime = dto.startTime;
            }
            else {
                const dates = [];
                if (dto.startTime) {
                    dates.push((0, typeorm_1.MoreThanOrEqual)(dto.startTime));
                }
                if (dto.endTime) {
                    dates.push((0, typeorm_1.LessThanOrEqual)(dto.endTime));
                }
                where.createTime = (0, typeorm_1.And)(...dates);
            }
        }
        result.total = await this.db.waterTest.count(where);
        if (result.total > 0) {
            result.rows = await this.db.waterTest.pagination(dto.pageNo, dto.pageSize, where, null, { id: 'DESC' });
            if (result.rows.length > 0) {
                const userIds = [];
                result.rows.forEach(row => {
                    if (row.userId > 0 && !userIds.includes(row.userId)) {
                        userIds.push(row.userId);
                    }
                });
                if (userIds.length > 0) {
                    const users = await this.db.user.find({ id: (0, typeorm_1.In)(userIds) }, { id: true, nickname: true, avatar: true });
                    if (users.length > 0) {
                        result.rows.forEach(row => {
                            if (row.userId > 0) {
                                const user = users.find(item => item.id == row.userId);
                                if (user) {
                                    row.user = user;
                                }
                            }
                        });
                    }
                }
            }
        }
        return result;
    }
};
exports.WaterTestService = WaterTestService;
exports.WaterTestService = WaterTestService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof db_service_1.DbService !== "undefined" && db_service_1.DbService) === "function" ? _a : Object])
], WaterTestService);


/***/ }),
/* 182 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.WaterTestController = void 0;
const response_util_1 = __webpack_require__(62);
const common_1 = __webpack_require__(3);
const dto_pipe_1 = __webpack_require__(65);
const page_dto_1 = __webpack_require__(183);
const water_test_service_1 = __webpack_require__(181);
let WaterTestController = class WaterTestController {
    constructor(service) {
        this.service = service;
    }
    async page(dto, req) {
        const result = await this.service.page(dto);
        return response_util_1.ResponseUtilService.successRes(result);
    }
};
exports.WaterTestController = WaterTestController;
__decorate([
    (0, common_1.Post)('page'),
    __param(0, (0, common_1.Body)(new dto_pipe_1.DtoPipe({ skipMissingProperties: true }))),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [typeof (_b = typeof page_dto_1.default !== "undefined" && page_dto_1.default) === "function" ? _b : Object, Object]),
    __metadata("design:returntype", Promise)
], WaterTestController.prototype, "page", null);
exports.WaterTestController = WaterTestController = __decorate([
    (0, common_1.Controller)('waterTest'),
    __metadata("design:paramtypes", [typeof (_a = typeof water_test_service_1.WaterTestService !== "undefined" && water_test_service_1.WaterTestService) === "function" ? _a : Object])
], WaterTestController);


/***/ }),
/* 183 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const pagination_dto_1 = __webpack_require__(67);
const class_validator_1 = __webpack_require__(68);
class PageDto extends pagination_dto_1.default {
}
exports["default"] = PageDto;
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "deviceId", void 0);
__decorate([
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "status", void 0);
__decorate([
    (0, class_validator_1.IsNumber)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "startTime", void 0);
__decorate([
    (0, class_validator_1.IsNumber)(),
    (0, class_validator_1.IsOptional)(),
    __metadata("design:type", Number)
], PageDto.prototype, "endTime", void 0);


/***/ })
/******/ 	]);
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;

Object.defineProperty(exports, "__esModule", ({ value: true }));
const core_1 = __webpack_require__(1);
const admin_module_1 = __webpack_require__(2);
const configure_1 = __webpack_require__(6);
async function bootstrap() {
    console.log('starting.....');
    const app = await core_1.NestFactory.create(admin_module_1.AdminModule);
    const configure = app.get(configure_1.ConfigureService);
    const apiPrefix = configure.get('API_PRE_FIX');
    const port = Number(configure.get('HTTP_PORT'));
    let url = 'http://localhost:' + port;
    if (apiPrefix != undefined && apiPrefix.length > 0) {
        url += ('/' + apiPrefix);
        app.setGlobalPrefix(apiPrefix);
    }
    await app.listen(port);
    console.log('url:' + url);
}
bootstrap();

})();

/******/ })()
;